Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1638216
| Path | csiph.com!news.redatomik.org!news.albasani.net!tahina.priv.at!bofh.it!news.nic.it!robomod |
|---|---|
| From | Jeff Layton <jlayton@redhat.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v4 24/27][RFC] nfs: convert to new errseq_t based error tracking for writeback errors |
| Date | Tue, 09 May 2017 18:00:02 +0200 |
| Message-ID | <tFfIm-3IS-17@gated-at.bofh.it> (permalink) |
| References | <tFfIm-3IS-7@gated-at.bofh.it> |
| X-Original-To | linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, linux-xfs@vger.kernel.org, cluster-devel@redhat.com, linux-f2fs-devel@lists.sourceforge.net, v9fs-developer@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-block@vger.kernel.org |
| Dmarc-Filter | OpenDMARC Filter v1.3.2 mx1.redhat.com 8FDD680C0A |
| Authentication-Results | ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com |
| Authentication-Results | ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jlayton@redhat.com |
| Dkim-Filter | OpenDKIM Filter v2.11.0 mx1.redhat.com 8FDD680C0A |
| X-Scanned-By | MIMEDefang 2.79 on 10.5.11.15 |
| X-Greylist | Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 09 May 2017 15:50:55 +0000 (UTC) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 107 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | dhowells@redhat.com, akpm@linux-foundation.org, hch@infradead.org, ross.zwisler@linux.intel.com, mawilcox@microsoft.com, jack@suse.com, viro@zeniv.linux.org.uk, corbet@lwn.net, neilb@suse.de, clm@fb.com, tytso@mit.edu, axboe@kernel.dk, josef@toxicpanda.com, hubcap@omnibond.com, rpeterso@redhat.com, bo.li.liu@oracle.com |
| X-Original-Date | Tue, 9 May 2017 11:49:27 -0400 |
| X-Original-Message-ID | <20170509154930.29524-25-jlayton@redhat.com> |
| X-Original-References | <20170509154930.29524-1-jlayton@redhat.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1638216 |
Show key headers only | View raw
Drop the ERROR_WRITE flag and convert the error field in the context to
a errseq_t. Add a new wb_err_cursor to track the reporting of the
errseq_t. In principle, we could use the f_wb_err field in struct file
for that, but that's problematic with the stock reporting in call_fsync.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/nfs/file.c | 19 +++++++++++--------
fs/nfs/inode.c | 5 +++--
fs/nfs/write.c | 2 +-
include/linux/nfs_fs.h | 3 ++-
4 files changed, 17 insertions(+), 12 deletions(-)
I did this on a lark to see how it would be, but I don't think this is
really better than what's there already. There may be a better way to
provide the right semantics without using an errseq_t here.
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 668213984d68..fd4d2b381d4b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -212,21 +212,24 @@ nfs_file_fsync_commit(struct file *file, loff_t start, loff_t end, int datasync)
{
struct nfs_open_context *ctx = nfs_file_open_context(file);
struct inode *inode = file_inode(file);
- int have_error, do_resend, status;
- int ret = 0;
+ int do_resend, status;
+ int ret;
dprintk("NFS: fsync file(%pD2) datasync %d\n", file, datasync);
nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
do_resend = test_and_clear_bit(NFS_CONTEXT_RESEND_WRITES, &ctx->flags);
- have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
+ clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
status = nfs_commit_inode(inode, FLUSH_SYNC);
- have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
- if (have_error) {
- ret = xchg(&ctx->error, 0);
- if (ret)
- goto out;
+ ret = errseq_check(&ctx->wb_err, READ_ONCE(ctx->wb_err_cursor));
+ if (ret) {
+ /* Use f_lock to serialize changes to wb_err_cursor */
+ spin_lock(&file->f_lock);
+ ret = errseq_check_and_advance(&ctx->wb_err, &ctx->wb_err_cursor);
+ spin_unlock(&file->f_lock);
}
+ if (ret)
+ goto out;
if (status < 0) {
ret = status;
goto out;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index f489a5a71bd5..ca85f6b39e3b 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -869,7 +869,8 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry,
ctx->state = NULL;
ctx->mode = f_mode;
ctx->flags = 0;
- ctx->error = 0;
+ ctx->wb_err = 0;
+ ctx->wb_err_cursor = 0;
ctx->flock_owner = (fl_owner_t)filp;
nfs_init_lock_context(&ctx->lock_context);
ctx->lock_context.open_context = ctx;
@@ -978,7 +979,7 @@ void nfs_file_clear_open_context(struct file *filp)
* We fatal error on write before. Try to writeback
* every page again.
*/
- if (ctx->error < 0)
+ if (errseq_check(&ctx->wb_err, ctx->wb_err_cursor))
invalidate_inode_pages2(inode->i_mapping);
filp->private_data = NULL;
spin_lock(&inode->i_lock);
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index abb2c8a3be42..95a5b4ac6714 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -94,7 +94,7 @@ static void nfs_writehdr_free(struct nfs_pgio_header *hdr)
static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
{
- ctx->error = error;
+ errseq_set(&ctx->wb_err, error);
smp_wmb();
set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
}
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 287f34161086..336adf1a38f7 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -76,7 +76,8 @@ struct nfs_open_context {
#define NFS_CONTEXT_ERROR_WRITE (0)
#define NFS_CONTEXT_RESEND_WRITES (1)
#define NFS_CONTEXT_BAD (2)
- int error;
+ errseq_t wb_err; /* where wb errors are tracked */
+ errseq_t wb_err_cursor; /* reporting cursor */
struct list_head list;
struct nfs4_threshold *mdsthreshold;
--
2.9.3
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH v4 24/27][RFC] nfs: convert to new errseq_t based error tracking for writeback errors Jeff Layton <jlayton@redhat.com> - 2017-05-09 18:00 +0200
csiph-web