From patchwork Thu Sep 9 20:22:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1526289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=YsbJXB29; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H59RZ2Gv9z9sX3; Fri, 10 Sep 2021 06:22:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mOQZI-0001uD-QZ; Thu, 09 Sep 2021 20:22:44 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mOQZH-0001tC-EA for kernel-team@lists.ubuntu.com; Thu, 09 Sep 2021 20:22:43 +0000 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 39A9E3F302 for ; Thu, 9 Sep 2021 20:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1631218963; bh=SLEEu5Mceu9P6aDdwJvWCMLYsF02ilcAxQ5WKIbPB9Y=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YsbJXB29JxWNxRUg4UYhcOcSuAjcZy+9iYxk3oMr+/uT8gEZHQjRW/y1v0if1BNAg 4MRePvxk3MmxGfrK/UUlsLR1rdEt9Jr7VMYUMXtFSeb2rxCRrbQOJPKZqBZGZR/pHZ XDQAErYJ06kkI6bd/e9bBW4XhNUhfwAVIwP0oGsfVYk+lkhBrCg6XZccYMWjYIuQUJ YCuHwKUqmcsJ8jOMOug3cdlcJWKmIEab3clVs0fdcyFzBEa0Yun4Zm+HEEO3Pva/Rn dTDjEsMwZd1ItFBfjeyG8dfsN9iBa+JRnk4TNvbNbM2Q49hLFAn/mdLDDKU1nCSciw pwwi0riOGKdBA== Received: by mail-qt1-f198.google.com with SMTP id r5-20020ac85e85000000b0029bd6ee5179so9510756qtx.18 for ; Thu, 09 Sep 2021 13:22:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SLEEu5Mceu9P6aDdwJvWCMLYsF02ilcAxQ5WKIbPB9Y=; b=mhSLTy/3QXvfPppsHd75kdYxmRVvNXe7DXTYgJ8l9F4DA2gOBRZ7yYfXHWxmUE/fzG vFFBHOyZ8SqPX+7hcopxyMTkjoi96ukFObXCMuXI2+npSSoV4CjY47VXdAaYQpD+CC7h IcfOesD2d7FR7MW+dEN+oFKoSuZjtgtqBmKD03NIsNU/eeIyvAAzxVLiGRgdk9+7Yg6j vRWdVcXQPCrLuxDEgxVveNtuI2NC7OR72EpDl1DDbYJGxLEmmQoukSgoEjUPANoxwT59 cLlXhDUy89lVYqsYqeoRpwLbEfwK39u3fN8eF7wEFFXItomjuQr469P0JI5IzRdokQw+ 9O1A== X-Gm-Message-State: AOAM530+h5VfwcXWhVTPUCadjAc+bQYrTM+HamM0NSNQb6hBzRy7+NU+ HpE9CBj5mZlgQl2HjXwJP0Mnqv80oLzPku8DnQB/HtRkZtqylmbt8d5JxP2+nLJyVFX/9BYhWNR fl5kN6zGPOMZYPC/teA3sXF/FCucyw5PBChyJaFUVfQ== X-Received: by 2002:a05:620a:530:: with SMTP id h16mr4443638qkh.460.1631218962036; Thu, 09 Sep 2021 13:22:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx3MS6F3BkaiJk4XHrZHG97SM5ZmFWdb0DT8hoSAGMoooIPMo3FEwJgGRAAF8WthnYob//GA== X-Received: by 2002:a05:620a:530:: with SMTP id h16mr4443620qkh.460.1631218961828; Thu, 09 Sep 2021 13:22:41 -0700 (PDT) Received: from mfo-t470.. ([2804:14c:4e1:8732:e256:1fca:b0d8:d6a8]) by smtp.gmail.com with ESMTPSA id t64sm2172210qkd.71.2021.09.09.13.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 13:22:41 -0700 (PDT) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [B][PATCH 1/5] jbd2: introduce/export functions jbd2_journal_submit|finish_inode_data_buffers() Date: Thu, 9 Sep 2021 17:22:27 -0300 Message-Id: <20210909202230.886329-7-mfo@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909202230.886329-1-mfo@canonical.com> References: <20210909202230.886329-1-mfo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1847340 Export functions that implement the current behavior done for an inode in journal_submit|finish_inode_data_buffers(). No functional change. Signed-off-by: Mauricio Faria de Oliveira Suggested-by: Jan Kara Reviewed-by: Jan Kara Reviewed-by: Andreas Dilger Link: https://lore.kernel.org/r/20201006004841.600488-2-mfo@canonical.com Signed-off-by: Theodore Ts'o (backported from commit aa3c0c61f62d682259e3e66cdc01846290f9cd6c) [mfo: backport: commit.c/hunk 1 & journal.c/hunk 1: refresh one line.] Signed-off-by: Mauricio Faria de Oliveira --- fs/jbd2/commit.c | 36 ++++++++++++++++-------------------- fs/jbd2/journal.c | 2 ++ include/linux/jbd2.h | 4 ++++ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 6870103a0f59..7712428f5952 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -189,19 +189,17 @@ static int journal_wait_on_commit_record(journal_t *journal, * use writepages() because with dealyed allocation we may be doing * block allocation in writepages(). */ -static int journal_submit_inode_data_buffers(struct address_space *mapping, - loff_t dirty_start, loff_t dirty_end) +int jbd2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode) { - int ret; + struct address_space *mapping = jinode->i_vfs_inode->i_mapping; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = mapping->nrpages * 2, - .range_start = dirty_start, - .range_end = dirty_end, + .range_start = jinode->i_dirty_start, + .range_end = jinode->i_dirty_end, }; - ret = generic_writepages(mapping, &wbc); - return ret; + return generic_writepages(mapping, &wbc); } /* @@ -217,16 +215,11 @@ static int journal_submit_data_buffers(journal_t *journal, { struct jbd2_inode *jinode; int err, ret = 0; - struct address_space *mapping; spin_lock(&journal->j_list_lock); list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) { - loff_t dirty_start = jinode->i_dirty_start; - loff_t dirty_end = jinode->i_dirty_end; - if (!(jinode->i_flags & JI_WRITE_DATA)) continue; - mapping = jinode->i_vfs_inode->i_mapping; jinode->i_flags |= JI_COMMIT_RUNNING; spin_unlock(&journal->j_list_lock); /* @@ -236,8 +229,7 @@ static int journal_submit_data_buffers(journal_t *journal, * only allocated blocks here. */ trace_jbd2_submit_inode_data(jinode->i_vfs_inode); - err = journal_submit_inode_data_buffers(mapping, dirty_start, - dirty_end); + err = jbd2_journal_submit_inode_data_buffers(jinode); if (!ret) ret = err; spin_lock(&journal->j_list_lock); @@ -250,6 +242,15 @@ static int journal_submit_data_buffers(journal_t *journal, return ret; } +int jbd2_journal_finish_inode_data_buffers(struct jbd2_inode *jinode) +{ + struct address_space *mapping = jinode->i_vfs_inode->i_mapping; + + return filemap_fdatawait_range_keep_errors(mapping, + jinode->i_dirty_start, + jinode->i_dirty_end); +} + /* * Wait for data submitted for writeout, refile inodes to proper * transaction if needed. @@ -264,16 +265,11 @@ 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) { - loff_t dirty_start = jinode->i_dirty_start; - loff_t dirty_end = jinode->i_dirty_end; - if (!(jinode->i_flags & JI_WAIT_DATA)) continue; jinode->i_flags |= JI_COMMIT_RUNNING; spin_unlock(&journal->j_list_lock); - err = filemap_fdatawait_range_keep_errors( - jinode->i_vfs_inode->i_mapping, dirty_start, - dirty_end); + err = jbd2_journal_finish_inode_data_buffers(jinode); if (!ret) ret = err; spin_lock(&journal->j_list_lock); diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 3f73cf90eccf..286ff71b517b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -99,6 +99,8 @@ EXPORT_SYMBOL(jbd2_journal_inode_add_write); EXPORT_SYMBOL(jbd2_journal_inode_add_wait); EXPORT_SYMBOL(jbd2_journal_inode_ranged_write); EXPORT_SYMBOL(jbd2_journal_inode_ranged_wait); +EXPORT_SYMBOL(jbd2_journal_submit_inode_data_buffers); +EXPORT_SYMBOL(jbd2_journal_finish_inode_data_buffers); EXPORT_SYMBOL(jbd2_journal_init_jbd_inode); EXPORT_SYMBOL(jbd2_journal_release_jbd_inode); EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate); diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index e9dd94518fd9..86871b53b402 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1421,6 +1421,10 @@ extern int jbd2_journal_inode_ranged_write(handle_t *handle, extern int jbd2_journal_inode_ranged_wait(handle_t *handle, struct jbd2_inode *inode, loff_t start_byte, loff_t length); +extern int jbd2_journal_submit_inode_data_buffers( + struct jbd2_inode *jinode); +extern int jbd2_journal_finish_inode_data_buffers( + struct jbd2_inode *jinode); extern int jbd2_journal_begin_ordered_truncate(journal_t *journal, struct jbd2_inode *inode, loff_t new_size); extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);