diff mbox

[1/3] NFS: add get_nfs_lock_context, find_nfs_lock_context

Message ID 55019f777691bf13781699d70cdaea6504311c89.1459512820.git.bcodding@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Coddington April 1, 2016, 3:34 p.m. UTC
Create a method for acquiring a nfs_lock_context reference which
will be used later within fscache, and rename nfs_get_lock_context to
nfs_find_lock_context to prepare it for finding or allocating a lock
context based upon a file pointer.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/direct.c        |    4 ++--
 fs/nfs/file.c          |    2 +-
 fs/nfs/inode.c         |   11 +++++++++--
 fs/nfs/nfs42proc.c     |    8 ++++----
 fs/nfs/pagelist.c      |    2 +-
 include/linux/nfs_fs.h |    3 ++-
 6 files changed, 19 insertions(+), 11 deletions(-)

Comments

kernel test robot April 1, 2016, 4:45 p.m. UTC | #1
Hi Benjamin,

[auto build test ERROR on v4.6-rc1]
[also build test ERROR on next-20160401]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Benjamin-Coddington/Include-OFD-lock-owners-when-looking-up-state/20160401-233801
config: mips-jz4740 (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

Note: the linux-review/Benjamin-Coddington/Include-OFD-lock-owners-when-looking-up-state/20160401-233801 HEAD e6973cc5e04cb6af43dbba362969dbf6ddcf7740 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   fs/nfs/file.c: In function 'do_unlk':
>> fs/nfs/file.c:759:32: error: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type [-Werror=incompatible-pointer-types]
     l_ctx = nfs_find_lock_context(nfs_file_open_context(filp));
                                   ^
   In file included from fs/nfs/file.c:25:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   cc1: some warnings being treated as errors
--
   fs/nfs/direct.c: In function 'nfs_file_direct_read':
>> fs/nfs/direct.c:599:32: error: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type [-Werror=incompatible-pointer-types]
     l_ctx = nfs_find_lock_context(dreq->ctx);
                                   ^
   In file included from fs/nfs/direct.c:51:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   fs/nfs/direct.c: In function 'nfs_file_direct_write':
   fs/nfs/direct.c:1032:32: error: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type [-Werror=incompatible-pointer-types]
     l_ctx = nfs_find_lock_context(dreq->ctx);
                                   ^
   In file included from fs/nfs/direct.c:51:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   cc1: some warnings being treated as errors
--
   fs/nfs/pagelist.c: In function 'nfs_create_request':
>> fs/nfs/pagelist.c:332:32: error: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type [-Werror=incompatible-pointer-types]
     l_ctx = nfs_find_lock_context(ctx);
                                   ^
   In file included from fs/nfs/pagelist.c:20:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   cc1: some warnings being treated as errors

vim +/nfs_find_lock_context +759 fs/nfs/file.c

   753		/*
   754		 * Flush all pending writes before doing anything
   755		 * with locks..
   756		 */
   757		vfs_fsync(filp, 0);
   758	
 > 759		l_ctx = nfs_find_lock_context(nfs_file_open_context(filp));
   760		if (!IS_ERR(l_ctx)) {
   761			status = nfs_iocounter_wait(l_ctx);
   762			nfs_put_lock_context(l_ctx);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot April 1, 2016, 5:03 p.m. UTC | #2
Hi Benjamin,

[auto build test ERROR on v4.6-rc1]
[also build test ERROR on next-20160401]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Benjamin-Coddington/Include-OFD-lock-owners-when-looking-up-state/20160401-233801
config: sparc64-allyesconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

Note: the linux-review/Benjamin-Coddington/Include-OFD-lock-owners-when-looking-up-state/20160401-233801 HEAD e6973cc5e04cb6af43dbba362969dbf6ddcf7740 builds fine.
      It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

   fs/nfs/file.c: In function 'do_unlk':
>> fs/nfs/file.c:759:10: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     l_ctx = nfs_find_lock_context(nfs_file_open_context(filp));
             ^
   In file included from fs/nfs/file.c:25:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
--
>> fs/nfs/inode.c:728:26: error: conflicting types for 'nfs_find_lock_context'
    struct nfs_lock_context *nfs_find_lock_context(struct nfs_open_context *ctx)
                             ^
   In file included from fs/nfs/inode.c:29:0:
   include/linux/nfs_fs.h:368:33: note: previous declaration of 'nfs_find_lock_context' was here
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from fs/nfs/inode.c:16:
   fs/nfs/inode.c:754:19: error: conflicting types for 'nfs_find_lock_context'
    EXPORT_SYMBOL_GPL(nfs_find_lock_context);
                      ^
   include/linux/export.h:57:21: note: in definition of macro '__EXPORT_SYMBOL'
     extern typeof(sym) sym;     \
                        ^
>> fs/nfs/inode.c:754:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(nfs_find_lock_context);
    ^
   In file included from fs/nfs/inode.c:29:0:
   include/linux/nfs_fs.h:368:33: note: previous declaration of 'nfs_find_lock_context' was here
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
--
   fs/nfs/direct.c: In function 'nfs_file_direct_read':
>> fs/nfs/direct.c:599:10: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     l_ctx = nfs_find_lock_context(dreq->ctx);
             ^
   In file included from fs/nfs/direct.c:51:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   fs/nfs/direct.c: In function 'nfs_file_direct_write':
   fs/nfs/direct.c:1032:10: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     l_ctx = nfs_find_lock_context(dreq->ctx);
             ^
   In file included from fs/nfs/direct.c:51:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
--
   fs/nfs/pagelist.c: In function 'nfs_create_request':
>> fs/nfs/pagelist.c:332:10: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     l_ctx = nfs_find_lock_context(ctx);
             ^
   In file included from fs/nfs/pagelist.c:20:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
--
   fs/nfs/nfs42proc.c: In function 'nfs42_proc_fallocate':
>> fs/nfs/nfs42proc.c:64:9: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     lock = nfs_find_lock_context(nfs_file_open_context(filep));
            ^
   In file included from fs/nfs/nfs42proc.c:10:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   fs/nfs/nfs42proc.c: In function 'nfs42_proc_llseek':
   fs/nfs/nfs42proc.c:174:9: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     lock = nfs_find_lock_context(nfs_file_open_context(filep));
            ^
   In file included from fs/nfs/nfs42proc.c:10:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   fs/nfs/nfs42proc.c: In function 'nfs42_proc_clone':
   fs/nfs/nfs42proc.c:368:13: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     src_lock = nfs_find_lock_context(nfs_file_open_context(src_f));
                ^
   In file included from fs/nfs/nfs42proc.c:10:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^
   fs/nfs/nfs42proc.c:375:13: warning: passing argument 1 of 'nfs_find_lock_context' from incompatible pointer type
     dst_lock = nfs_find_lock_context(nfs_file_open_context(dst_f));
                ^
   In file included from fs/nfs/nfs42proc.c:10:0:
   include/linux/nfs_fs.h:368:33: note: expected 'struct file *' but argument is of type 'struct nfs_open_context *'
    extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
                                    ^

vim +/nfs_find_lock_context +728 fs/nfs/inode.c

   722			atomic_inc(&pos->count);
   723			return pos;
   724		} while ((pos = list_entry(pos->list.next, typeof(*pos), list)) != head);
   725		return NULL;
   726	}
   727	
 > 728	struct nfs_lock_context *nfs_find_lock_context(struct nfs_open_context *ctx)
   729	{
   730		struct nfs_lock_context *res, *new = NULL;
   731		struct inode *inode = d_inode(ctx->dentry);
   732	
   733		spin_lock(&inode->i_lock);
   734		res = __nfs_find_lock_context(ctx);
   735		if (res == NULL) {
   736			spin_unlock(&inode->i_lock);
   737			new = kmalloc(sizeof(*new), GFP_KERNEL);
   738			if (new == NULL)
   739				return ERR_PTR(-ENOMEM);
   740			nfs_init_lock_context(new);
   741			spin_lock(&inode->i_lock);
   742			res = __nfs_find_lock_context(ctx);
   743			if (res == NULL) {
   744				list_add_tail(&new->list, &ctx->lock_context.list);
   745				new->open_context = ctx;
   746				res = new;
   747				new = NULL;
   748			}
   749		}
   750		spin_unlock(&inode->i_lock);
   751		kfree(new);
   752		return res;
   753	}
 > 754	EXPORT_SYMBOL_GPL(nfs_find_lock_context);
   755	
   756	struct nfs_lock_context *get_nfs_lock_context(struct nfs_lock_context *l_ctx)
   757	{

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 7a0cfd3..5f833fa 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -596,7 +596,7 @@  ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
 	dreq->bytes_left = count;
 	dreq->io_start = pos;
 	dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
-	l_ctx = nfs_get_lock_context(dreq->ctx);
+	l_ctx = nfs_find_lock_context(dreq->ctx);
 	if (IS_ERR(l_ctx)) {
 		result = PTR_ERR(l_ctx);
 		goto out_release;
@@ -1029,7 +1029,7 @@  ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
 	dreq->bytes_left = iov_iter_count(iter);
 	dreq->io_start = pos;
 	dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp));
-	l_ctx = nfs_get_lock_context(dreq->ctx);
+	l_ctx = nfs_find_lock_context(dreq->ctx);
 	if (IS_ERR(l_ctx)) {
 		result = PTR_ERR(l_ctx);
 		goto out_release;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 748bb81..f99c085 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -754,7 +754,7 @@  do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
 	 */
 	vfs_fsync(filp, 0);
 
-	l_ctx = nfs_get_lock_context(nfs_file_open_context(filp));
+	l_ctx = nfs_find_lock_context(nfs_file_open_context(filp));
 	if (!IS_ERR(l_ctx)) {
 		status = nfs_iocounter_wait(l_ctx);
 		nfs_put_lock_context(l_ctx);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 86faecf..5d484e5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -725,7 +725,7 @@  static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context
 	return NULL;
 }
 
-struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
+struct nfs_lock_context *nfs_find_lock_context(struct nfs_open_context *ctx)
 {
 	struct nfs_lock_context *res, *new = NULL;
 	struct inode *inode = d_inode(ctx->dentry);
@@ -751,7 +751,14 @@  struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
 	kfree(new);
 	return res;
 }
-EXPORT_SYMBOL_GPL(nfs_get_lock_context);
+EXPORT_SYMBOL_GPL(nfs_find_lock_context);
+
+struct nfs_lock_context *get_nfs_lock_context(struct nfs_lock_context *l_ctx)
+{
+	atomic_inc(&l_ctx->count);
+	return l_ctx;
+}
+EXPORT_SYMBOL_GPL(get_nfs_lock_context);
 
 void nfs_put_lock_context(struct nfs_lock_context *l_ctx)
 {
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index dff8346..f9b0f25 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -61,7 +61,7 @@  static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
 	struct nfs_lock_context *lock;
 	int err;
 
-	lock = nfs_get_lock_context(nfs_file_open_context(filep));
+	lock = nfs_find_lock_context(nfs_file_open_context(filep));
 	if (IS_ERR(lock))
 		return PTR_ERR(lock);
 
@@ -171,7 +171,7 @@  loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
 	struct nfs_lock_context *lock;
 	loff_t err;
 
-	lock = nfs_get_lock_context(nfs_file_open_context(filep));
+	lock = nfs_find_lock_context(nfs_file_open_context(filep));
 	if (IS_ERR(lock))
 		return PTR_ERR(lock);
 
@@ -365,14 +365,14 @@  int nfs42_proc_clone(struct file *src_f, struct file *dst_f,
 	if (!nfs_server_capable(inode, NFS_CAP_CLONE))
 		return -EOPNOTSUPP;
 
-	src_lock = nfs_get_lock_context(nfs_file_open_context(src_f));
+	src_lock = nfs_find_lock_context(nfs_file_open_context(src_f));
 	if (IS_ERR(src_lock))
 		return PTR_ERR(src_lock);
 
 	src_exception.inode = file_inode(src_f);
 	src_exception.state = src_lock->open_context->state;
 
-	dst_lock = nfs_get_lock_context(nfs_file_open_context(dst_f));
+	dst_lock = nfs_find_lock_context(nfs_file_open_context(dst_f));
 	if (IS_ERR(dst_lock)) {
 		err = PTR_ERR(dst_lock);
 		goto out_put_src_lock;
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 8ce4f61..b3e5366 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -329,7 +329,7 @@  nfs_create_request(struct nfs_open_context *ctx, struct page *page,
 		return ERR_PTR(-ENOMEM);
 
 	/* get lock context early so we can deal with alloc failures */
-	l_ctx = nfs_get_lock_context(ctx);
+	l_ctx = nfs_find_lock_context(ctx);
 	if (IS_ERR(l_ctx)) {
 		nfs_page_free(req);
 		return ERR_CAST(l_ctx);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 67300f8..e93e285 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -365,7 +365,8 @@  extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fm
 extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
 extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
 extern void nfs_file_clear_open_context(struct file *flip);
-extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
+extern struct nfs_lock_context *nfs_find_lock_context(struct file *file);
+extern struct nfs_lock_context *get_nfs_lock_context(struct nfs_lock_context *l_ctx);
 extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
 extern u64 nfs_compat_user_ino64(u64 fileid);
 extern void nfs_fattr_init(struct nfs_fattr *fattr);