Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp380757ybl; Wed, 4 Dec 2019 04:25:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwTTTq9jlOcIUhLj9LOBeXiv3aESaxByYJ32svUUXyW1CSag3bCZ9STenhhKHyo7vvWsG9x X-Received: by 2002:a9d:74c7:: with SMTP id a7mr2287539otl.7.1575462354865; Wed, 04 Dec 2019 04:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575462354; cv=none; d=google.com; s=arc-20160816; b=W8R7e39khjxV9pdDBrBY2UKJ0IxSIZVhDru/aJxNcLRuc3DUA6ma56bxAM2Y6b1yAa SN3mU454FhNESKPFdK9HxxcY8M9yF0MRgc8fCqSOiqOo7TQVawVGtHqze8HuPqYyZwfX T5Sp4G8ozqT4gR7quIuJUo/sCzEoH/F8HJY7/JQsV97O7E7YzAZKN9T3myHhjZ3LGNup UGtdPln3LOY4Po0Kr8uAfvDxOQDehtEVt6Y7srBE532itERVGzrhlPlV00ZXXonpPe7Z FY/SGQQ2gO4ghwFb/O+1qkYEEvlRXFPR2QG+32tBKzd/Gu1deSdMcNUP3THr3pocWJvj U+Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=dJrftsk4sABULfeqfosIwBh27CiGmSl/299geLmf66g=; b=ivFYkj+VSPUCrj7yvSPFZjvsyxR44aEJY2S0ygAHyuzysPUaNG/3ZhdOznfavVSCk4 UdO3Xkb1L2ch1KYUew8PDP6Byz0Ma6s4GIu+5SpoDDI9Tb3U+AkXN32oj6uGHvfhZFtP ZpTdQ7Qz8GEGqjriu+5IZjCMgvP8+TmMhv7UEIXQI18S+gpmbo4PPlgUqDRQNOLIlqU9 Rc5njgHYQdjMbshVVRrCT1Ez2nWC0KPwgQECVkRLBSM/fKfSv/niQqygb25uiHUISLh2 gZsn9Ac9BCuyhZB4s4uaot5pBtI5RXs/WWD66g6/esqZnHR/dCxjzI4lgSBKM0oDWUTa mg/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a205si3089437oii.95.2019.12.04.04.25.44; Wed, 04 Dec 2019 04:25:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfLDMZ3 (ORCPT + 99 others); Wed, 4 Dec 2019 07:25:29 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:45776 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727845AbfLDMZ2 (ORCPT ); Wed, 4 Dec 2019 07:25:28 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 651B52258A56AF8FFAB0; Wed, 4 Dec 2019 20:25:26 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Dec 2019 20:25:19 +0800 From: "zhangyi (F)" To: CC: , , , , , Subject: [PATCH v3 4/4] jbd2: clean __jbd2_journal_abort_hard() and __journal_abort_soft() Date: Wed, 4 Dec 2019 20:46:14 +0800 Message-ID: <20191204124614.45424-5-yi.zhang@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20191204124614.45424-1-yi.zhang@huawei.com> References: <20191204124614.45424-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org __jbd2_journal_abort_hard() has never been used, now we can merge __jbd2_journal_abort_hard() and __journal_abort_soft() these two functions into jbd2_journal_abort() and remove them. Signed-off-by: zhangyi (F) --- fs/jbd2/journal.c | 103 ++++++++++++++++++------------------------- include/linux/jbd2.h | 1 - 2 files changed, 42 insertions(+), 62 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 93be6e0311da..e59d9b6e4596 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -96,7 +96,6 @@ EXPORT_SYMBOL(jbd2_journal_release_jbd_inode); EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate); EXPORT_SYMBOL(jbd2_inode_cache); -static void __journal_abort_soft (journal_t *journal, int errno); static int jbd2_journal_create_slab(size_t slab_size); #ifdef CONFIG_JBD2_DEBUG @@ -805,7 +804,7 @@ int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr, "at offset %lu on %s\n", __func__, blocknr, journal->j_devname); err = -EIO; - __journal_abort_soft(journal, err); + jbd2_journal_abort(journal, err); } } else { *retp = blocknr; /* +journal->j_blk_offset */ @@ -2065,64 +2064,6 @@ int jbd2_journal_wipe(journal_t *journal, int write) return err; } -/* - * Journal abort has very specific semantics, which we describe - * for journal abort. - * - * Two internal functions, which provide abort to the jbd layer - * itself are here. - */ - -/* - * Quick version for internal journal use (doesn't lock the journal). - * Aborts hard --- we mark the abort as occurred, but do _nothing_ else, - * and don't attempt to make any other journal updates. - */ -void __jbd2_journal_abort_hard(journal_t *journal) -{ - transaction_t *transaction; - - if (journal->j_flags & JBD2_ABORT) - return; - - printk(KERN_ERR "Aborting journal on device %s.\n", - journal->j_devname); - - write_lock(&journal->j_state_lock); - journal->j_flags |= JBD2_ABORT; - transaction = journal->j_running_transaction; - if (transaction) - __jbd2_log_start_commit(journal, transaction->t_tid); - write_unlock(&journal->j_state_lock); -} - -/* Soft abort: record the abort error status in the journal superblock, - * but don't do any other IO. */ -static void __journal_abort_soft (journal_t *journal, int errno) -{ - int old_errno; - - write_lock(&journal->j_state_lock); - old_errno = journal->j_errno; - if (!journal->j_errno || errno == -ESHUTDOWN) - journal->j_errno = errno; - - if (journal->j_flags & JBD2_ABORT) { - write_unlock(&journal->j_state_lock); - if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN) - jbd2_journal_update_sb_errno(journal); - return; - } - write_unlock(&journal->j_state_lock); - - __jbd2_journal_abort_hard(journal); - - jbd2_journal_update_sb_errno(journal); - write_lock(&journal->j_state_lock); - journal->j_flags |= JBD2_REC_ERR; - write_unlock(&journal->j_state_lock); -} - /** * void jbd2_journal_abort () - Shutdown the journal immediately. * @journal: the journal to shutdown. @@ -2166,7 +2107,47 @@ static void __journal_abort_soft (journal_t *journal, int errno) void jbd2_journal_abort(journal_t *journal, int errno) { - __journal_abort_soft(journal, errno); + transaction_t *transaction; + + /* + * ESHUTDOWN always takes precedence because a file system check + * caused by any other journal abort error is not required after + * a shutdown triggered. + */ + write_lock(&journal->j_state_lock); + if (journal->j_flags & JBD2_ABORT) { + int old_errno = journal->j_errno; + + write_unlock(&journal->j_state_lock); + if (old_errno != -ESHUTDOWN && errno == -ESHUTDOWN) { + journal->j_errno = errno; + jbd2_journal_update_sb_errno(journal); + } + return; + } + + /* + * Mark the abort as occurred and start current running transaction + * to release all journaled buffer. + */ + pr_err("Aborting journal on device %s.\n", journal->j_devname); + + journal->j_flags |= JBD2_ABORT; + journal->j_errno = errno; + transaction = journal->j_running_transaction; + if (transaction) + __jbd2_log_start_commit(journal, transaction->t_tid); + write_unlock(&journal->j_state_lock); + + /* + * Record errno to the journal super block, so that fsck and jbd2 + * layer could realise that a filesystem check is needed. + */ + jbd2_journal_update_sb_errno(journal); + + write_lock(&journal->j_state_lock); + journal->j_flags |= JBD2_REC_ERR; + write_unlock(&journal->j_state_lock); } /** diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 603fbc4e2f70..e3e271bfb0e7 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1402,7 +1402,6 @@ extern int jbd2_journal_skip_recovery (journal_t *); extern void jbd2_journal_update_sb_errno(journal_t *); extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t, unsigned long, int); -extern void __jbd2_journal_abort_hard (journal_t *); extern void jbd2_journal_abort (journal_t *, int); extern int jbd2_journal_errno (journal_t *); extern void jbd2_journal_ack_err (journal_t *); -- 2.17.2