From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 03/14] libxfs: make libxfs_buf_get_map return an error code
Date: Wed, 19 Feb 2020 17:44:47 -0800 [thread overview]
Message-ID: <158216308793.603628.12888791331568943049.stgit@magnolia> (raw)
In-Reply-To: <158216306957.603628.16404096061228456718.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Convert libxfs_buf_get_map() to return numeric error codes like most
everywhere else in xfsprogs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libxfs/libxfs_io.h | 20 +++++++++----
libxfs/rdwr.c | 78 ++++++++++++++++++++++++++++------------------------
libxfs/trans.c | 16 +++++++----
repair/prefetch.c | 6 +++-
4 files changed, 69 insertions(+), 51 deletions(-)
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 2a451ab2..189db8d8 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -144,9 +144,9 @@ extern struct cache_operations libxfs_bcache_operations;
#define libxfs_buf_get(dev, daddr, len) \
libxfs_trace_getbuf(__FUNCTION__, __FILE__, __LINE__, \
(dev), (daddr), (len))
-#define libxfs_buf_get_map(dev, map, nmaps, flags) \
+#define libxfs_buf_get_map(dev, map, nmaps, flags, bpp) \
libxfs_trace_getbuf_map(__FUNCTION__, __FILE__, __LINE__, \
- (dev), (map), (nmaps), (flags))
+ (dev), (map), (nmaps), (flags), (bpp))
#define libxfs_buf_relse(buf) \
libxfs_trace_putbuf(__FUNCTION__, __FILE__, __LINE__, (buf))
@@ -161,8 +161,9 @@ void libxfs_trace_dirtybuf(const char *func, const char *file, int line,
struct xfs_buf *libxfs_trace_getbuf(const char *func, const char *file,
int line, struct xfs_buftarg *btp, xfs_daddr_t daddr,
size_t len);
-extern xfs_buf_t *libxfs_trace_getbuf_map(const char *, const char *, int,
- struct xfs_buftarg *, struct xfs_buf_map *, int, int);
+int libxfs_trace_getbuf_map(const char *func, const char *file, int line,
+ struct xfs_buftarg *btp, struct xfs_buf_map *map,
+ int nmaps, int flags, struct xfs_buf **bpp);
extern void libxfs_trace_putbuf (const char *, const char *, int,
xfs_buf_t *);
@@ -171,8 +172,8 @@ extern void libxfs_trace_putbuf (const char *, const char *, int,
extern xfs_buf_t *libxfs_buf_read_map(struct xfs_buftarg *, struct xfs_buf_map *,
int, int, const struct xfs_buf_ops *);
void libxfs_buf_dirty(struct xfs_buf *bp, int flags);
-extern xfs_buf_t *libxfs_buf_get_map(struct xfs_buftarg *,
- struct xfs_buf_map *, int, int);
+int libxfs_buf_get_map(struct xfs_buftarg *btp, struct xfs_buf_map *maps,
+ int nmaps, int flags, struct xfs_buf **bpp);
void libxfs_buf_relse(struct xfs_buf *);
static inline struct xfs_buf*
@@ -181,9 +182,14 @@ libxfs_buf_get(
xfs_daddr_t blkno,
size_t numblks)
{
+ struct xfs_buf *bp;
+ int error;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- return libxfs_buf_get_map(target, &map, 1, 0);
+ error = libxfs_buf_get_map(target, &map, 1, 0, &bp);
+ if (error)
+ return NULL;
+ return bp;
}
static inline struct xfs_buf*
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 6a7a66ae..4e1665c0 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -392,10 +392,9 @@ libxfs_log_header(
xfs_buf_t *libxfs_buf_read_map(struct xfs_buftarg *, struct xfs_buf_map *,
int, int, const struct xfs_buf_ops *);
int libxfs_writebuf(xfs_buf_t *, int);
-struct xfs_buf *libxfs_buf_get(struct xfs_buftarg *btp, xfs_daddr_t daddr,
- size_t len);
-xfs_buf_t *libxfs_buf_get_map(struct xfs_buftarg *, struct xfs_buf_map *,
- int, int);
+int libxfs_buf_get_map(struct xfs_buftarg *btp,
+ struct xfs_buf_map *maps, int nmaps, int flags,
+ struct xfs_buf **bpp);
void libxfs_buf_relse(struct xfs_buf *);
#define __add_trace(bp, func, file, line) \
@@ -450,19 +449,27 @@ libxfs_trace_getbuf(
struct xfs_buf *bp;
DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
- bp = libxfs_buf_get_map(target, &map, 1, 0);
+ libxfs_buf_get_map(target, &map, 1, 0, &bp);
__add_trace(bp, func, file, line);
return bp;
}
-xfs_buf_t *
-libxfs_trace_getbuf_map(const char *func, const char *file, int line,
- struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
- int flags)
+int
+libxfs_trace_getbuf_map(
+ const char *func,
+ const char *file,
+ int line,
+ struct xfs_buftarg *btp,
+ struct xfs_buf_map *map,
+ int nmaps,
+ int flags,
+ struct xfs_buf **bpp)
{
- xfs_buf_t *bp = libxfs_buf_get_map(btp, map, nmaps, flags);
- __add_trace(bp, func, file, line);
- return bp;
+ int error;
+
+ error = libxfs_buf_get_map(btp, map, nmaps, flags, bpp);
+ __add_trace(*bpp, func, file, line);
+ return error;
}
void
@@ -812,25 +819,20 @@ reset_buf_state(
LIBXFS_B_UPTODATE);
}
-static struct xfs_buf *
+static int
__libxfs_buf_get_map(
struct xfs_buftarg *btp,
struct xfs_buf_map *map,
int nmaps,
- int flags)
+ int flags,
+ struct xfs_buf **bpp)
{
struct xfs_bufkey key = {NULL};
- struct xfs_buf *bp;
int i;
- int error;
- if (nmaps == 1) {
- error = libxfs_getbuf_flags(btp, map[0].bm_bn, map[0].bm_len,
- flags, &bp);
- if (error)
- return NULL;
- return bp;
- }
+ if (nmaps == 1)
+ return libxfs_getbuf_flags(btp, map[0].bm_bn, map[0].bm_len,
+ flags, bpp);
key.buftarg = btp;
key.blkno = map[0].bm_bn;
@@ -840,21 +842,25 @@ __libxfs_buf_get_map(
key.map = map;
key.nmaps = nmaps;
- error = __cache_lookup(&key, flags, &bp);
- if (error)
- return NULL;
- return bp;
+ return __cache_lookup(&key, flags, bpp);
}
-struct xfs_buf *
-libxfs_buf_get_map(struct xfs_buftarg *btp, struct xfs_buf_map *map,
- int nmaps, int flags)
+int
+libxfs_buf_get_map(
+ struct xfs_buftarg *btp,
+ struct xfs_buf_map *map,
+ int nmaps,
+ int flags,
+ struct xfs_buf **bpp)
{
- struct xfs_buf *bp;
+ int error;
- bp = __libxfs_buf_get_map(btp, map, nmaps, flags);
- reset_buf_state(bp);
- return bp;
+ error = __libxfs_buf_get_map(btp, map, nmaps, flags, bpp);
+ if (error)
+ return error;
+
+ reset_buf_state(*bpp);
+ return 0;
}
void
@@ -1056,8 +1062,8 @@ libxfs_buf_read_map(struct xfs_buftarg *btp, struct xfs_buf_map *map, int nmaps,
return libxfs_readbuf(btp, map[0].bm_bn, map[0].bm_len,
flags, ops);
- bp = __libxfs_buf_get_map(btp, map, nmaps, 0);
- if (!bp)
+ error = __libxfs_buf_get_map(btp, map, nmaps, 0, &bp);
+ if (error)
return NULL;
bp->b_error = 0;
diff --git a/libxfs/trans.c b/libxfs/trans.c
index f4ce23a7..a7407dc3 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -423,11 +423,16 @@ libxfs_trans_get_buf_map(
int nmaps,
xfs_buf_flags_t flags)
{
- xfs_buf_t *bp;
+ struct xfs_buf *bp;
struct xfs_buf_log_item *bip;
+ int error;
- if (!tp)
- return libxfs_buf_get_map(target, map, nmaps, 0);
+ if (!tp) {
+ error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
+ if (error)
+ return NULL;
+ return bp;
+ }
/*
* If we find the buffer in the cache with this transaction
@@ -445,10 +450,9 @@ libxfs_trans_get_buf_map(
return bp;
}
- bp = libxfs_buf_get_map(target, map, nmaps, 0);
- if (bp == NULL) {
+ error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
+ if (error)
return NULL;
- }
ASSERT(!bp->b_error);
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 7f705cc0..587b3b1f 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -113,6 +113,7 @@ pf_queue_io(
{
struct xfs_buf *bp;
xfs_fsblock_t fsbno = XFS_DADDR_TO_FSB(mp, map[0].bm_bn);
+ int error;
/*
* Never block on a buffer lock here, given that the actual repair
@@ -120,8 +121,9 @@ pf_queue_io(
* the lock holder is either reading it from disk himself or
* completely overwriting it this behaviour is perfectly fine.
*/
- bp = libxfs_buf_get_map(mp->m_dev, map, nmaps, LIBXFS_GETBUF_TRYLOCK);
- if (!bp)
+ error = -libxfs_buf_get_map(mp->m_dev, map, nmaps, LIBXFS_GETBUF_TRYLOCK,
+ &bp);
+ if (error)
return;
if (bp->b_flags & LIBXFS_B_UPTODATE) {
next prev parent reply other threads:[~2020-02-20 1:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 1:44 [PATCH 00/14] xfsprogs: make buffer functions return error codes Darrick J. Wong
2020-02-20 1:44 ` [PATCH 01/14] libxfs: make __cache_lookup return an error code Darrick J. Wong
2020-02-21 14:55 ` Christoph Hellwig
2020-02-20 1:44 ` [PATCH 02/14] libxfs: make libxfs_getbuf_flags " Darrick J. Wong
2020-02-21 14:56 ` Christoph Hellwig
2020-02-20 1:44 ` Darrick J. Wong [this message]
2020-02-21 14:57 ` [PATCH 03/14] libxfs: make libxfs_buf_get_map " Christoph Hellwig
2020-02-21 16:01 ` Darrick J. Wong
2020-02-20 1:44 ` [PATCH 04/14] libxfs: refactor libxfs_readbuf out of existence Darrick J. Wong
2020-02-21 15:00 ` Christoph Hellwig
2020-02-21 22:13 ` Darrick J. Wong
2020-02-20 1:45 ` [PATCH 05/14] libxfs: make libxfs_buf_read_map return an error code Darrick J. Wong
2020-02-21 15:03 ` Christoph Hellwig
2020-02-21 16:15 ` Darrick J. Wong
2020-02-21 16:28 ` Christoph Hellwig
2020-02-20 1:45 ` [PATCH 06/14] xfs: make xfs_buf_read_map " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 07/14] xfs: make xfs_buf_get " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 08/14] xfs: make xfs_buf_get_uncached " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 09/14] xfs: make xfs_buf_read " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 10/14] xfs: make xfs_trans_get_buf_map " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 11/14] xfs: make xfs_trans_get_buf " Darrick J. Wong
2020-02-20 1:45 ` [PATCH 12/14] xfs: remove the xfs_btree_get_buf[ls] functions Darrick J. Wong
2020-02-20 1:45 ` [PATCH 13/14] xfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers Darrick J. Wong
2020-02-20 1:45 ` [PATCH 14/14] xfs: remove unnecessary null pointer checks from _read_agf callers Darrick J. Wong
2020-02-20 1:53 ` [PATCH 00/14] xfsprogs: make buffer functions return error codes Darrick J. Wong
2020-02-25 0:14 [PATCH v2 " Darrick J. Wong
2020-02-25 0:14 ` [PATCH 03/14] libxfs: make libxfs_buf_get_map return an error code 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=158216308793.603628.12888791331568943049.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.