From: Christoph Hellwig <hch@lst.de>
To: linux-xfs@vger.kernel.org
Cc: Allison Collins <allison.henderson@oracle.com>
Subject: [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions
Date: Wed, 20 Nov 2019 12:17:20 +0100 [thread overview]
Message-ID: <20191120111727.16119-4-hch@lst.de> (raw)
In-Reply-To: <20191120111727.16119-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 0 with *nmap set to 0 to
signal that case in the return value instead of a nameless -1 return
code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_da_btree.c | 39 +++++++++++++-----------------------
fs/xfs/libxfs/xfs_da_btree.h | 3 +++
2 files changed, 17 insertions(+), 25 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index e078817fc26c..d85dd99d28a3 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2460,19 +2460,11 @@ xfs_da_shrink_inode(
return error;
}
-/*
- * Map the block we are given ready for reading. There are three possible return
- * values:
- * -1 - will be returned if we land in a hole and mappedbno == -2 so the
- * caller knows not to execute a subsequent read.
- * 0 - if we mapped the block successfully
- * >0 - positive error number if there was an error.
- */
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 **mapp,
int *nmaps)
@@ -2527,7 +2519,7 @@ xfs_dabuf_map(
invalid_mapping:
/* Caller ok with no mapping. */
- if (XFS_IS_CORRUPT(mp, mappedbno != -2)) {
+ if (XFS_IS_CORRUPT(mp, !flags & XFS_DABUF_MAP_HOLE_OK)) {
error = -EFSCORRUPTED;
if (xfs_error_level >= XFS_ERRLEVEL_LOW) {
xfs_alert(mp, "%s: bno %u inode %llu",
@@ -2575,13 +2567,11 @@ xfs_da_get_buf(
goto done;
}
- error = xfs_dabuf_map(dp, bno, mappedbno, whichfork, &mapp, &nmap);
- if (error) {
- /* mapping a hole is not an error, but we don't continue */
- if (error == -1)
- error = 0;
+ error = xfs_dabuf_map(dp, bno,
+ mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
+ whichfork, &mapp, &nmap);
+ if (error || nmap == 0)
goto out_free;
- }
bp = xfs_trans_get_buf_map(tp, mp->m_ddev_targp, mapp, nmap, 0);
done:
@@ -2630,13 +2620,11 @@ xfs_da_read_buf(
goto done;
}
- error = xfs_dabuf_map(dp, bno, mappedbno, whichfork, &mapp, &nmap);
- if (error) {
- /* mapping a hole is not an error, but we don't continue */
- if (error == -1)
- error = 0;
+ error = xfs_dabuf_map(dp, bno,
+ mappedbno == -1 ? XFS_DABUF_MAP_HOLE_OK : 0,
+ whichfork, &mapp, &nmap);
+ if (error || !nmap)
goto out_free;
- }
error = xfs_trans_read_buf_map(mp, tp, mp->m_ddev_targp, mapp, nmap, 0,
&bp, ops);
@@ -2677,11 +2665,12 @@ xfs_da_reada_buf(
mapp = ↦
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 ed3b558a9c1a..64624d5717c9 100644
--- a/fs/xfs/libxfs/xfs_da_btree.h
+++ b/fs/xfs/libxfs/xfs_da_btree.h
@@ -194,6 +194,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
next prev parent reply other threads:[~2019-11-20 11:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 11:17 clean up the dabuf mappedbno interface v2 Christoph Hellwig
2019-11-20 11:17 ` [PATCH 01/10] xfs: simplify mappedbno handling in xfs_da_{get,read}_buf Christoph Hellwig
2019-11-20 11:17 ` [PATCH 02/10] xfs: refactor xfs_dabuf_map Christoph Hellwig
2019-11-20 18:24 ` Darrick J. Wong
2019-11-20 11:17 ` Christoph Hellwig [this message]
2019-11-20 18:17 ` [PATCH 03/10] xfs: improve the xfs_dabuf_map calling conventions Darrick J. Wong
2019-11-20 18:20 ` Christoph Hellwig
2019-11-21 5:44 ` Darrick J. Wong
2019-11-21 6:06 ` Christoph Hellwig
2019-11-21 7:15 ` Darrick J. Wong
2019-11-21 7:20 ` Christoph Hellwig
2019-11-20 19:02 ` Darrick J. Wong
2019-11-20 11:17 ` [PATCH 04/10] xfs: remove the mappedbno argument to xfs_da_reada_buf Christoph Hellwig
2019-11-20 11:17 ` [PATCH 05/10] xfs: remove the mappedbno argument to xfs_attr3_leaf_read Christoph Hellwig
2019-11-20 11:17 ` [PATCH 06/10] xfs: remove the mappedbno argument to xfs_dir3_leaf_read Christoph Hellwig
2019-11-20 11:17 ` [PATCH 07/10] xfs: remove the mappedbno argument to xfs_dir3_leafn_read Christoph Hellwig
2019-11-20 11:17 ` [PATCH 08/10] xfs: split xfs_da3_node_read Christoph Hellwig
2019-11-20 11:17 ` [PATCH 09/10] xfs: remove the mappedbno argument to xfs_da_read_buf Christoph Hellwig
2019-11-20 11:17 ` [PATCH 10/10] xfs: remove the mappedbno argument to xfs_da_get_buf 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=20191120111727.16119-4-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