Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFS: Fix a compile warning when !(CONFIG_NFS_V3 || CONFIG_NFS_V4)
@ 2014-09-09  5:26 Trond Myklebust
  2014-09-09 15:02 ` Weston Andros Adamson
  0 siblings, 1 reply; 2+ messages in thread
From: Trond Myklebust @ 2014-09-09  5:26 UTC (permalink / raw)
  To: linux-nfs; +Cc: Anna Schumaker, Weston Andros Adamson

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>
---
 fs/nfs/write.c | 74 +++++++++++++++++++++++++++++++++-------------------------
 1 file 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;
 static void nfs_clear_request_commit(struct nfs_page *req);
 static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
 				      struct inode *inode);
+static struct nfs_page *
+nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
+						struct page *page);
 
 static struct kmem_cache *nfs_wdata_cachep;
 static mempool_t *nfs_wdata_mempool;
@@ -95,38 +98,6 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
 }
 
 /*
- * nfs_page_search_commits_for_head_request_locked
- *
- * Search through commit lists on @inode for the head request for @page.
- * Must be called while holding the inode (which is cinfo) lock.
- *
- * Returns the head request if found, or NULL if not found.
- */
-static struct nfs_page *
-nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
-						struct page *page)
-{
-	struct nfs_page *freq, *t;
-	struct nfs_commit_info cinfo;
-	struct inode *inode = &nfsi->vfs_inode;
-
-	nfs_init_cinfo_from_inode(&cinfo, inode);
-
-	/* search through pnfs commit lists */
-	freq = pnfs_search_commit_reqs(inode, &cinfo, page);
-	if (freq)
-		return freq->wb_head;
-
-	/* Linearly search the commit list for the correct request */
-	list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
-		if (freq->wb_page == page)
-			return freq->wb_head;
-	}
-
-	return NULL;
-}
-
-/*
  * nfs_page_find_head_request_locked - find head request associated with @page
  *
  * must be called while holding the inode lock.
@@ -750,6 +721,38 @@ nfs_mark_request_dirty(struct nfs_page *req)
 }
 
 #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
+/*
+ * nfs_page_search_commits_for_head_request_locked
+ *
+ * Search through commit lists on @inode for the head request for @page.
+ * Must be called while holding the inode (which is cinfo) lock.
+ *
+ * Returns the head request if found, or NULL if not found.
+ */
+static struct nfs_page *
+nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
+						struct page *page)
+{
+	struct nfs_page *freq, *t;
+	struct nfs_commit_info cinfo;
+	struct inode *inode = &nfsi->vfs_inode;
+
+	nfs_init_cinfo_from_inode(&cinfo, inode);
+
+	/* search through pnfs commit lists */
+	freq = pnfs_search_commit_reqs(inode, &cinfo, page);
+	if (freq)
+		return freq->wb_head;
+
+	/* Linearly search the commit list for the correct request */
+	list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
+		if (freq->wb_page == page)
+			return freq->wb_head;
+	}
+
+	return NULL;
+}
+
 /**
  * nfs_request_add_commit_list - add request to a commit list
  * @req: pointer to a struct nfs_page
@@ -868,6 +871,13 @@ int nfs_write_need_commit(struct nfs_pgio_header *hdr)
 }
 
 #else
+static struct nfs_page *
+nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
+						struct page *page)
+{
+	return NULL;
+}
+
 static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
 				      struct inode *inode)
 {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] NFS: Fix a compile warning when !(CONFIG_NFS_V3 || CONFIG_NFS_V4)
  2014-09-09  5:26 [PATCH] NFS: Fix a compile warning when !(CONFIG_NFS_V3 || CONFIG_NFS_V4) Trond Myklebust
@ 2014-09-09 15:02 ` Weston Andros Adamson
  0 siblings, 0 replies; 2+ messages in thread
From: Weston Andros Adamson @ 2014-09-09 15:02 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: linux-nfs list, Anna Schumaker

Thanks Trond,

This looks good. Sorry for breaking the NFSv2 only case.

-dros



On Sep 9, 2014, at 1:26 AM, Trond Myklebust <trond.myklebust@primarydata.com> wrote:

> 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>
> ---
> fs/nfs/write.c | 74 +++++++++++++++++++++++++++++++++-------------------------
> 1 file 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;
> static void nfs_clear_request_commit(struct nfs_page *req);
> static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
> 				      struct inode *inode);
> +static struct nfs_page *
> +nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
> +						struct page *page);
> 
> static struct kmem_cache *nfs_wdata_cachep;
> static mempool_t *nfs_wdata_mempool;
> @@ -95,38 +98,6 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
> }
> 
> /*
> - * nfs_page_search_commits_for_head_request_locked
> - *
> - * Search through commit lists on @inode for the head request for @page.
> - * Must be called while holding the inode (which is cinfo) lock.
> - *
> - * Returns the head request if found, or NULL if not found.
> - */
> -static struct nfs_page *
> -nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
> -						struct page *page)
> -{
> -	struct nfs_page *freq, *t;
> -	struct nfs_commit_info cinfo;
> -	struct inode *inode = &nfsi->vfs_inode;
> -
> -	nfs_init_cinfo_from_inode(&cinfo, inode);
> -
> -	/* search through pnfs commit lists */
> -	freq = pnfs_search_commit_reqs(inode, &cinfo, page);
> -	if (freq)
> -		return freq->wb_head;
> -
> -	/* Linearly search the commit list for the correct request */
> -	list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
> -		if (freq->wb_page == page)
> -			return freq->wb_head;
> -	}
> -
> -	return NULL;
> -}
> -
> -/*
>  * nfs_page_find_head_request_locked - find head request associated with @page
>  *
>  * must be called while holding the inode lock.
> @@ -750,6 +721,38 @@ nfs_mark_request_dirty(struct nfs_page *req)
> }
> 
> #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
> +/*
> + * nfs_page_search_commits_for_head_request_locked
> + *
> + * Search through commit lists on @inode for the head request for @page.
> + * Must be called while holding the inode (which is cinfo) lock.
> + *
> + * Returns the head request if found, or NULL if not found.
> + */
> +static struct nfs_page *
> +nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
> +						struct page *page)
> +{
> +	struct nfs_page *freq, *t;
> +	struct nfs_commit_info cinfo;
> +	struct inode *inode = &nfsi->vfs_inode;
> +
> +	nfs_init_cinfo_from_inode(&cinfo, inode);
> +
> +	/* search through pnfs commit lists */
> +	freq = pnfs_search_commit_reqs(inode, &cinfo, page);
> +	if (freq)
> +		return freq->wb_head;
> +
> +	/* Linearly search the commit list for the correct request */
> +	list_for_each_entry_safe(freq, t, &cinfo.mds->list, wb_list) {
> +		if (freq->wb_page == page)
> +			return freq->wb_head;
> +	}
> +
> +	return NULL;
> +}
> +
> /**
>  * nfs_request_add_commit_list - add request to a commit list
>  * @req: pointer to a struct nfs_page
> @@ -868,6 +871,13 @@ int nfs_write_need_commit(struct nfs_pgio_header *hdr)
> }
> 
> #else
> +static struct nfs_page *
> +nfs_page_search_commits_for_head_request_locked(struct nfs_inode *nfsi,
> +						struct page *page)
> +{
> +	return NULL;
> +}
> +
> static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
> 				      struct inode *inode)
> {
> -- 
> 1.9.3
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-09 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09  5:26 [PATCH] NFS: Fix a compile warning when !(CONFIG_NFS_V3 || CONFIG_NFS_V4) Trond Myklebust
2014-09-09 15:02 ` Weston Andros Adamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox