diff options
author | NeilBrown <neilb@suse.com> | 2016-10-13 00:26:47 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2016-12-01 17:57:27 -0500 |
commit | 532d4def2f95623a9b8b2cef7723e14521377911 (patch) | |
tree | f596be47ef2cf430d009b7f6d864d9ea7c7dab62 /fs/nfs/inode.c | |
parent | b184b5c38e4640585126e44ef84f2dbdd0d23d5a (diff) |
NFSv4: add flock_owner to open context
An open file description (struct file) in a given process can be
associated with two different lock owners.
It can have a Posix lock owner which will be different in each process
that has a fd on the file.
It can have a Flock owner which will be the same in all processes.
When searching for a lock stateid to use, we need to consider both of these
owners
So add a new "flock_owner" to the "nfs_open_context" (of which there
is one for each open file description).
This flock_owner does not need to be reference-counted as there is a
1-1 relation between 'struct file' and nfs open contexts,
and it will never be part of a list of contexts. So there is no need
for a 'flock_context' - just the owner is enough.
The io_count included in the (Posix) lock_context provides no
guarantee that all read-aheads that could use the state have
completed, so not supporting it for flock locks in not a serious
problem. Synchronization between flock and read-ahead can be added
later if needed.
When creating an open_context for a non-openning create call, we don't have
a 'struct file' to pass in, so the lock context gets initialized with
a NULL owner, but this will never be used.
The flock_owner is not used at all in this patch, that will come later.
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index fd9913249713..3a7601fe9dee 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -796,7 +796,9 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) | |||
796 | } | 796 | } |
797 | EXPORT_SYMBOL_GPL(nfs_close_context); | 797 | EXPORT_SYMBOL_GPL(nfs_close_context); |
798 | 798 | ||
799 | struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode) | 799 | struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, |
800 | fmode_t f_mode, | ||
801 | struct file *filp) | ||
800 | { | 802 | { |
801 | struct nfs_open_context *ctx; | 803 | struct nfs_open_context *ctx; |
802 | struct rpc_cred *cred = rpc_lookup_cred(); | 804 | struct rpc_cred *cred = rpc_lookup_cred(); |
@@ -815,6 +817,7 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f | |||
815 | ctx->mode = f_mode; | 817 | ctx->mode = f_mode; |
816 | ctx->flags = 0; | 818 | ctx->flags = 0; |
817 | ctx->error = 0; | 819 | ctx->error = 0; |
820 | ctx->flock_owner = (fl_owner_t)filp; | ||
818 | nfs_init_lock_context(&ctx->lock_context); | 821 | nfs_init_lock_context(&ctx->lock_context); |
819 | ctx->lock_context.open_context = ctx; | 822 | ctx->lock_context.open_context = ctx; |
820 | INIT_LIST_HEAD(&ctx->list); | 823 | INIT_LIST_HEAD(&ctx->list); |
@@ -939,7 +942,7 @@ int nfs_open(struct inode *inode, struct file *filp) | |||
939 | { | 942 | { |
940 | struct nfs_open_context *ctx; | 943 | struct nfs_open_context *ctx; |
941 | 944 | ||
942 | ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode); | 945 | ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp); |
943 | if (IS_ERR(ctx)) | 946 | if (IS_ERR(ctx)) |
944 | return PTR_ERR(ctx); | 947 | return PTR_ERR(ctx); |
945 | nfs_file_set_open_context(filp, ctx); | 948 | nfs_file_set_open_context(filp, ctx); |