linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 5/9] xfs: don't log the inode in xfs_fs_map_blocks if it wasn't modified
Date: Wed, 30 Oct 2019 11:04:15 -0700	[thread overview]
Message-ID: <20191030180419.13045-6-hch@lst.de> (raw)
In-Reply-To: <20191030180419.13045-1-hch@lst.de>

Even if we are asked for a write layout there is no point in logging
the inode unless we actually modified it in some way.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_pnfs.c | 42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 3634ffff3b07..ada46e9f5ff1 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -150,30 +150,24 @@ xfs_fs_map_blocks(
 
 	ASSERT(!nimaps || imap.br_startblock != DELAYSTARTBLOCK);
 
-	if (write) {
-		enum xfs_prealloc_flags	flags = 0;
-
-		if (!nimaps || imap.br_startblock == HOLESTARTBLOCK) {
-			/*
-			 * xfs_iomap_write_direct() expects to take ownership of
-			 * the shared ilock.
-			 */
-			xfs_ilock(ip, XFS_ILOCK_SHARED);
-			error = xfs_iomap_write_direct(ip, offset, length,
-						       &imap, nimaps);
-			if (error)
-				goto out_unlock;
-
-			/*
-			 * Ensure the next transaction is committed
-			 * synchronously so that the blocks allocated and
-			 * handed out to the client are guaranteed to be
-			 * present even after a server crash.
-			 */
-			flags |= XFS_PREALLOC_SET | XFS_PREALLOC_SYNC;
-		}
-
-		error = xfs_update_prealloc_flags(ip, flags);
+	if (write && (!nimaps || imap.br_startblock == HOLESTARTBLOCK)) {
+		/*
+		 * xfs_iomap_write_direct() expects to take ownership of the
+		 * shared ilock.
+		 */
+		xfs_ilock(ip, XFS_ILOCK_SHARED);
+		error = xfs_iomap_write_direct(ip, offset, length, &imap,
+					       nimaps);
+		if (error)
+			goto out_unlock;
+
+		/*
+		 * Ensure the next transaction is committed synchronously so
+		 * that the blocks allocated and handed out to the client are
+		 * guaranteed to be present even after a server crash.
+		 */
+		error = xfs_update_prealloc_flags(ip,
+				XFS_PREALLOC_SET | XFS_PREALLOC_SYNC);
 		if (error)
 			goto out_unlock;
 	}
-- 
2.20.1


  parent reply	other threads:[~2019-10-30 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 18:04 a few iomap / bmap cleanups v2 Christoph Hellwig
2019-10-30 18:04 ` [PATCH 1/9] xfs: simplify xfs_iomap_eof_align_last_fsb Christoph Hellwig
2019-10-30 18:04 ` [PATCH 2/9] xfs: mark xfs_eof_alignment static Christoph Hellwig
2019-10-30 18:04 ` [PATCH 3/9] xfs: remove the extsize argument to xfs_eof_alignment Christoph Hellwig
2019-10-30 19:36   ` Darrick J. Wong
2019-10-30 18:04 ` [PATCH 4/9] xfs: slightly tweak an assert in xfs_fs_map_blocks Christoph Hellwig
2019-10-30 19:26   ` Darrick J. Wong
2019-10-30 18:04 ` Christoph Hellwig [this message]
2019-10-30 19:31   ` [PATCH 5/9] xfs: don't log the inode in xfs_fs_map_blocks if it wasn't modified Darrick J. Wong
2019-10-30 18:04 ` [PATCH 6/9] xfs: simplify the xfs_iomap_write_direct calling conventions Christoph Hellwig
2019-10-30 18:04 ` [PATCH 7/9] xfs: refactor xfs_bmapi_allocate Christoph Hellwig
2019-10-30 18:04 ` [PATCH 8/9] xfs: move extent zeroing to xfs_bmapi_allocate Christoph Hellwig
2019-10-30 18:04 ` [PATCH 9/9] xfs: cleanup use of the XFS_ALLOC_ flags Christoph Hellwig

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=20191030180419.13045-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).