From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH 4/4] NFS: nfs_find_open_context() may only select open files
Date: Thu, 20 May 2021 12:39:02 -0400 [thread overview]
Message-ID: <20210520163902.215745-5-trondmy@kernel.org> (raw)
In-Reply-To: <20210520163902.215745-4-trondmy@kernel.org>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
If a file has already been closed, then it should not be selected to
support further I/O.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/inode.c | 4 ++++
include/linux/nfs_fs.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 529c4099f482..5ccc6b258ca5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1101,6 +1101,7 @@ EXPORT_SYMBOL_GPL(nfs_inode_attach_open_context);
void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
{
filp->private_data = get_nfs_open_context(ctx);
+ set_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
if (list_empty(&ctx->list))
nfs_inode_attach_open_context(ctx);
}
@@ -1120,6 +1121,8 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct
continue;
if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode)
continue;
+ if (!test_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags))
+ continue;
ctx = get_nfs_open_context(pos);
if (ctx)
break;
@@ -1135,6 +1138,7 @@ void nfs_file_clear_open_context(struct file *filp)
if (ctx) {
struct inode *inode = d_inode(ctx->dentry);
+ clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
/*
* We fatal error on write before. Try to writeback
* every page again.
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index ffba254d2098..ce6474594872 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -84,6 +84,7 @@ struct nfs_open_context {
#define NFS_CONTEXT_RESEND_WRITES (1)
#define NFS_CONTEXT_BAD (2)
#define NFS_CONTEXT_UNLOCK (3)
+#define NFS_CONTEXT_FILE_OPEN (4)
int error;
struct list_head list;
--
2.31.1
next prev parent reply other threads:[~2021-05-20 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 16:38 [PATCH 0/4] Add support for application leases to NFSv4 trondmy
2021-05-20 16:38 ` [PATCH 1/4] NFSv4: Fix delegation return in cases where we have to retry trondmy
2021-05-20 16:39 ` [PATCH 2/4] NFSv4: Add lease breakpoints in case of a delegation recall or return trondmy
2021-05-20 16:39 ` [PATCH 3/4] NFSv4: Add support for application leases underpinned by a delegation trondmy
2021-05-20 16:39 ` trondmy [this message]
2021-05-20 18:29 ` [PATCH 1/4] NFSv4: Fix delegation return in cases where we have to retry J. Bruce Fields
2021-05-20 19:08 ` Trond Myklebust
2021-05-20 20:47 ` bfields
2021-05-20 21:14 ` Trond Myklebust
2021-05-21 20:23 ` bfields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210520163902.215745-5-trondmy@kernel.org \
--to=trondmy@kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox