From patchwork Wed May 31 12:45:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9756865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B5C360390 for ; Wed, 31 May 2017 12:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F568201BD for ; Wed, 31 May 2017 12:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 841C7283BA; Wed, 31 May 2017 12:47:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E548201BD for ; Wed, 31 May 2017 12:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751030AbdEaMrd (ORCPT ); Wed, 31 May 2017 08:47:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46194 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbdEaMqE (ORCPT ); Wed, 31 May 2017 08:46:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B141F97838; Wed, 31 May 2017 12:45:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B141F97838 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jlayton@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B141F97838 Received: from tleilax.poochiereds.net (ovpn-120-5.rdu2.redhat.com [10.10.120.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9417AC4517; Wed, 31 May 2017 12:45:57 +0000 (UTC) From: Jeff Layton To: Andrew Morton , Al Viro , Jan Kara , tytso@mit.edu, axboe@kernel.dk, mawilcox@microsoft.com, ross.zwisler@linux.intel.com, corbet@lwn.net Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 13/17] jbd2: conditionally handle errors using errseq_t based on FS_WB_ERRSEQ flag Date: Wed, 31 May 2017 08:45:36 -0400 Message-Id: <20170531124540.8782-14-jlayton@redhat.com> In-Reply-To: <20170531124540.8782-1-jlayton@redhat.com> References: <20170531124540.8782-1-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 May 2017 12:45:59 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Grab the current mapping->wb_err when linking a transaction to the list and stash it in the journal inode. Then we can use that as a "since" value when committing it to ensure that there were no writeback errors since the transaction was started. We do still need to perform old-style error handling too for now in journal_finish_inode_data_buffers. jbd2 is shared infrastructure between several filesystems. Eventually we should be able to remove the flag check and simplify this function again. For journal recovery, sample the wb_err early on and then pass that as the since value to sync_blockdev_since. Signed-off-by: Jeff Layton --- fs/jbd2/commit.c | 29 +++++++++++++++++++---------- fs/jbd2/recovery.c | 5 +++-- fs/jbd2/transaction.c | 1 + include/linux/jbd2.h | 3 +++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index b6b194ec1b4f..aea71e4bc9be 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -259,21 +259,30 @@ static int journal_finish_inode_data_buffers(journal_t *journal, /* For locking, see the comment in journal_submit_data_buffers() */ spin_lock(&journal->j_list_lock); list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { + struct inode *inode = jinode->i_vfs_inode; + if (!(jinode->i_flags & JI_WAIT_DATA)) continue; jinode->i_flags |= JI_COMMIT_RUNNING; spin_unlock(&journal->j_list_lock); - err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping); - if (err) { - /* - * Because AS_EIO is cleared by - * filemap_fdatawait_range(), set it again so - * that user process can get -EIO from fsync(). - */ - mapping_set_error(jinode->i_vfs_inode->i_mapping, -EIO); - - if (!ret) + if (inode->i_sb->s_type->fs_flags & FS_WB_ERRSEQ) { + err = filemap_fdatawait_since(inode->i_mapping, + jinode->i_since); + if (err && !ret) ret = err; + } else { + err = filemap_fdatawait(inode->i_mapping); + if (err) { + /* + * Because AS_EIO is cleared by + * filemap_fdatawait_range(), we must set it again so + * that user process can get -EIO from fsync() if + * non-errseq_t based error tracking is in play. + */ + mapping_set_error(inode->i_mapping, -EIO); + if (!ret) + ret = err; + } } spin_lock(&journal->j_list_lock); jinode->i_flags &= ~JI_COMMIT_RUNNING; diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 02dd3360cb20..06a8ee71848c 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -248,11 +248,12 @@ int jbd2_journal_recover(journal_t *journal) { int err, err2; journal_superblock_t * sb; - struct recovery_info info; + errseq_t since; memset(&info, 0, sizeof(info)); sb = journal->j_superblock; + since = filemap_sample_wb_err(journal->j_fs_dev->bd_inode->i_mapping); /* * The journal superblock's s_start field (the current log head) @@ -284,7 +285,7 @@ int jbd2_journal_recover(journal_t *journal) journal->j_transaction_sequence = ++info.end_transaction; jbd2_journal_clear_revoke(journal); - err2 = sync_blockdev(journal->j_fs_dev); + err2 = sync_blockdev_since(journal->j_fs_dev, since); if (!err) err = err2; /* Make sure all replayed data is on permanent storage */ diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 9ee4832b6f8b..e9e6af20a087 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -2535,6 +2535,7 @@ static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, /* Not on any transaction list... */ J_ASSERT(!jinode->i_next_transaction); jinode->i_transaction = transaction; + jinode->i_since = filemap_sample_wb_err(jinode->i_vfs_inode->i_mapping); list_add(&jinode->i_list, &transaction->t_inode_list); done: spin_unlock(&journal->j_list_lock); diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 606b6bce3a5b..b6901eac2d8e 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -439,6 +439,9 @@ struct jbd2_inode { /* Flags of inode [j_list_lock] */ unsigned long i_flags; + + /* Sampled writeback error at the time of transaction start */ + errseq_t i_since; }; struct jbd2_revoke_table_s;