aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-09-09 01:21:00 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-09-10 15:47:02 -0400
commit3a3908c8b09d5ec19d543836d4f38d240ae27fe8 (patch)
treeb5925398b0cc8c610f5587b51cd68eaefaf10bd5
parent921b81a8cd5a4acc2a009778d13eedd377362c4c (diff)
NFS: Fix a compile warning when !(CONFIG_NFS_V3 || CONFIG_NFS_V4)
gcc reports: linux/fs/nfs/write.c: In function ‘nfs_page_find_head_request_locked.isra.17’: linux/fs/nfs/write.c:121:64: warning: ‘cinfo.mds’ may be used uninitialized in this function [-Wmaybe-uninitialized] list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) { ^ linux/fs/nfs/write.c:110:25: note: ‘cinfo.mds’ was declared here struct nfs_commit_info cinfo; Reported-by: Anna Schumaker <Anna.Schumaker@netapp.com> Cc: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/write.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 3c5638f381cd..128d97f01d1c 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -49,6 +49,9 @@ static const struct nfs_rw_ops nfs_rw_write_ops;
49static void nfs_clear_request_commit(struct nfs_page *req); 49static void nfs_clear_request_commit(struct nfs_page *req);
50static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo, 50static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
51 struct inode *inode); 51 struct inode *inode);
52static struct nfs_page *
53nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
54 struct page *page);
52 55
53static struct kmem_cache *nfs_wdata_cachep; 56static struct kmem_cache *nfs_wdata_cachep;
54static mempool_t *nfs_wdata_mempool; 57static mempool_t *nfs_wdata_mempool;
@@ -95,38 +98,6 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
95} 98}
96 99
97/* 100/*
98 * nfs_page_search_commits_for_head_request_locked
99 *
100 * Search through commit lists on @inode for the head request for @page.
101 * Must be called while holding the inode (which is cinfo) lock.
102 *
103 * Returns the head request if found, or NULL if not found.
104 */
105static struct nfs_page *
106nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
107 struct page *page)
108{
109 struct nfs_page *freq, *t;
110 struct nfs_commit_info cinfo;
111 struct inode *inode = &nfsi->vfs_inode;
112
113 nfs_init_cinfo_from_inode(&cinfo, inode);
114
115 /* search through pnfs commit lists */
116 freq = pnfs_search_commit_reqs(inode, &cinfo, page);
117 if (freq)
118 return freq->wb_head;
119
120 /* Linearly search the commit list for the correct request */
121 list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
122 if (freq->wb_page == page)
123 return freq->wb_head;
124 }
125
126 return NULL;
127}
128
129/*
130 * nfs_page_find_head_request_locked - find head request associated with @page 101 * nfs_page_find_head_request_locked - find head request associated with @page
131 * 102 *
132 * must be called while holding the inode lock. 103 * must be called while holding the inode lock.
@@ -750,6 +721,38 @@ nfs_mark_request_dirty(struct nfs_page *req)
750} 721}
751 722
752#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4) 723#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
724/*
725 * nfs_page_search_commits_for_head_request_locked
726 *
727 * Search through commit lists on @inode for the head request for @page.
728 * Must be called while holding the inode (which is cinfo) lock.
729 *
730 * Returns the head request if found, or NULL if not found.
731 */
732static struct nfs_page *
733nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
734 struct page *page)
735{
736 struct nfs_page *freq, *t;
737 struct nfs_commit_info cinfo;
738 struct inode *inode = &nfsi->vfs_inode;
739
740 nfs_init_cinfo_from_inode(&cinfo, inode);
741
742 /* search through pnfs commit lists */
743 freq = pnfs_search_commit_reqs(inode, &cinfo, page);
744 if (freq)
745 return freq->wb_head;
746
747 /* Linearly search the commit list for the correct request */
748 list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
749 if (freq->wb_page == page)
750 return freq->wb_head;
751 }
752
753 return NULL;
754}
755
753/** 756/**
754 * nfs_request_add_commit_list - add request to a commit list 757 * nfs_request_add_commit_list - add request to a commit list
755 * @req: pointer to a struct nfs_page 758 * @req: pointer to a struct nfs_page
@@ -868,6 +871,13 @@ int nfs_write_need_commit(struct nfs_pgio_header *hdr)
868} 871}
869 872
870#else 873#else
874static struct nfs_page *
875nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
876 struct page *page)
877{
878 return NULL;
879}
880
871static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo, 881static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
872 struct inode *inode) 882 struct inode *inode)
873{ 883{