linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Cc: Allison Collins <allison.henderson@oracle.com>
Subject: [PATCH 2/9] xfs: improve the xfs_dabuf_map calling conventions
Date: Sat, 16 Nov 2019 19:22:07 +0100	[thread overview]
Message-ID: <20191116182214.23711-3-hch@lst.de> (raw)
In-Reply-To: <20191116182214.23711-1-hch@lst.de>

Use a flags argument with the XFS_DABUF_MAP_HOLE_OK flag to signal that
a hole is okay and not corruption, and return -ENOENT instead of the
nameless -1 to signal that case in the return value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_da_btree.c | 25 +++++++++++++++----------
 fs/xfs/libxfs/xfs_da_btree.h |  3 +++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 681fba5731c2..c26f139bcf00 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2571,7 +2571,7 @@ static int
 xfs_dabuf_map(
 	struct xfs_inode	*dp,
 	xfs_dablk_t		bno,
-	xfs_daddr_t		mappedbno,
+	unsigned int		flags,
 	int			whichfork,
 	struct xfs_buf_map	**map,
 	int			*nmaps)
@@ -2596,8 +2596,8 @@ xfs_dabuf_map(
 
 	if (!xfs_da_map_covers_blocks(nirecs, irecs, bno, nfsb)) {
 		/* Caller ok with no mapping. */
-		if (mappedbno == -2) {
-			error = -1;
+		if (flags & XFS_DABUF_MAP_HOLE_OK) {
+			error = -ENOENT;
 			goto out;
 		}
 
@@ -2655,10 +2655,12 @@ xfs_da_get_buf(
 		goto done;
 	}
 
-	error = xfs_dabuf_map(dp, bno, mappedbno, whichfork, &mapp, &nmap);
+	error = xfs_dabuf_map(dp, bno,
+			mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
+			whichfork, &mapp, &nmap);
 	if (error) {
 		/* mapping a hole is not an error, but we don't continue */
-		if (error == -1)
+		if (error == -ENOENT)
 			error = 0;
 		goto out_free;
 	}
@@ -2710,10 +2712,12 @@ xfs_da_read_buf(
 		goto done;
 	}
 
-	error = xfs_dabuf_map(dp, bno, mappedbno, whichfork, &mapp, &nmap);
+	error = xfs_dabuf_map(dp, bno,
+			mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
+			whichfork, &mapp, &nmap);
 	if (error) {
 		/* mapping a hole is not an error, but we don't continue */
-		if (error == -1)
+		if (error == -ENOENT)
 			error = 0;
 		goto out_free;
 	}
@@ -2757,11 +2761,12 @@ xfs_da_reada_buf(
 
 	mapp = &map;
 	nmap = 1;
-	error = xfs_dabuf_map(dp, bno, mappedbno, whichfork,
-				&mapp, &nmap);
+	error = xfs_dabuf_map(dp, bno,
+			mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
+			whichfork, &mapp, &nmap);
 	if (error) {
 		/* mapping a hole is not an error, but we don't continue */
-		if (error == -1)
+		if (error == -ENOENT)
 			error = 0;
 		goto out_free;
 	}
diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
index 5af4df71e92b..9ec0d0243e96 100644
--- a/fs/xfs/libxfs/xfs_da_btree.h
+++ b/fs/xfs/libxfs/xfs_da_btree.h
@@ -204,6 +204,9 @@ int	xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,
 /*
  * Utility routines.
  */
+
+#define XFS_DABUF_MAP_HOLE_OK	(1 << 0)
+
 int	xfs_da_grow_inode(xfs_da_args_t *args, xfs_dablk_t *new_blkno);
 int	xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno,
 			      int count);
-- 
2.20.1


  parent reply	other threads:[~2019-11-16 18:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-16 18:22 RFC: clean up the dabuf mappedbno interface Christoph Hellwig
2019-11-16 18:22 ` [PATCH 1/9] xfs: simplify mappedbno case from xfs_da_get_buf and xfs_da_read_buf Christoph Hellwig
2019-11-18 21:21   ` Darrick J. Wong
2019-11-16 18:22 ` Christoph Hellwig [this message]
2019-11-17 18:35   ` [PATCH 2/9] xfs: improve the xfs_dabuf_map calling conventions Darrick J. Wong
2019-11-18  6:25     ` Christoph Hellwig
2019-11-19 17:12       ` Darrick J. Wong
2019-11-19 17:15         ` Christoph Hellwig
2019-11-16 18:22 ` [PATCH 3/9] xfs: remove the mappedbno argument to xfs_da_reada_buf Christoph Hellwig
2019-11-18 21:22   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 4/9] xfs: remove the mappedbno argument to xfs_attr3_leaf_read Christoph Hellwig
2019-11-18 21:22   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 5/9] xfs: remove the mappedbno argument to xfs_dir3_leaf_read Christoph Hellwig
2019-11-18 21:23   ` Darrick J. Wong
2019-11-18 21:23   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 6/9] xfs: remove the mappedbno argument to xfs_dir3_leafn_read Christoph Hellwig
2019-11-18 21:23   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 7/9] xfs: split xfs_da3_node_read Christoph Hellwig
2019-11-18 21:24   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 8/9] xfs: remove the mappedbno argument to xfs_da_read_buf Christoph Hellwig
2019-11-18 21:29   ` Darrick J. Wong
2019-11-16 18:22 ` [PATCH 9/9] xfs: remove the mappedbno argument to xfs_da_get_buf Christoph Hellwig
2019-11-18 21:32   ` Darrick J. Wong

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=20191116182214.23711-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=allison.henderson@oracle.com \
    --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).