All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Dave Chinner <dchinner@redhat.com>
Subject: [PATCH 08/14] xfs: make xfs_buf_get_uncached return an error code
Date: Wed, 19 Feb 2020 17:45:21 -0800	[thread overview]
Message-ID: <158216312194.603628.5152582204376597051.stgit@magnolia> (raw)
In-Reply-To: <158216306957.603628.16404096061228456718.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Source kernel commit: 2842b6db3d539bec08d080b22635b6e8acaa30ec

Convert xfs_buf_get_uncached() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/libxfs_io.h        |    4 ++--
 libxfs/rdwr.c             |    8 +++++---
 libxfs/xfs_ag.c           |   21 ++++++++++++---------
 libxlog/xfs_log_recover.c |    7 +++++--
 mkfs/xfs_mkfs.c           |    8 +++++++-
 5 files changed, 31 insertions(+), 17 deletions(-)


diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 064587a6..6fbf976b 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -256,8 +256,8 @@ xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t len)
 	return 0;
 }
 
-struct xfs_buf *libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen,
-		int flags);
+int libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags,
+		struct xfs_buf **bpp);
 int libxfs_buf_read_uncached(struct xfs_buftarg *targ, xfs_daddr_t daddr,
 		size_t bblen, int flags, struct xfs_buf **bpp,
 		const struct xfs_buf_ops *ops);
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index a05e0fee..0bfe46f3 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1128,13 +1128,15 @@ libxfs_getbufr_uncached(
  * Allocate an uncached buffer that points nowhere.  The refcount will be 1,
  * and the cache node hash list will be empty to indicate that it's uncached.
  */
-struct xfs_buf *
+int
 libxfs_buf_get_uncached(
 	struct xfs_buftarg	*targ,
 	size_t			bblen,
-	int			flags)
+	int			flags,
+	struct xfs_buf		**bpp)
 {
-	return libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+	*bpp = libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+	return *bpp != NULL ? 0 : -ENOMEM;
 }
 
 /*
diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c
index 5bf6975d..73fb30cb 100644
--- a/libxfs/xfs_ag.c
+++ b/libxfs/xfs_ag.c
@@ -23,25 +23,28 @@
 #include "xfs_ag_resv.h"
 #include "xfs_health.h"
 
-static struct xfs_buf *
+static int
 xfs_get_aghdr_buf(
 	struct xfs_mount	*mp,
 	xfs_daddr_t		blkno,
 	size_t			numblks,
+	struct xfs_buf		**bpp,
 	const struct xfs_buf_ops *ops)
 {
 	struct xfs_buf		*bp;
+	int			error;
 
-	bp = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0);
-	if (!bp)
-		return NULL;
+	error = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0, &bp);
+	if (error)
+		return error;
 
 	xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
 	bp->b_bn = blkno;
 	bp->b_maps[0].bm_bn = blkno;
 	bp->b_ops = ops;
 
-	return bp;
+	*bpp = bp;
+	return 0;
 }
 
 static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id)
@@ -340,13 +343,13 @@ xfs_ag_init_hdr(
 	struct aghdr_init_data	*id,
 	aghdr_init_work_f	work,
 	const struct xfs_buf_ops *ops)
-
 {
 	struct xfs_buf		*bp;
+	int			error;
 
-	bp = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, ops);
-	if (!bp)
-		return -ENOMEM;
+	error = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, &bp, ops);
+	if (error)
+		return error;
 
 	(*work)(mp, bp, id);
 
diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c
index e7e57bd2..78fbafab 100644
--- a/libxlog/xfs_log_recover.c
+++ b/libxlog/xfs_log_recover.c
@@ -35,11 +35,13 @@ xlog_buf_bbcount_valid(
  * to map to a range of nbblks basic blocks at any valid (basic
  * block) offset within the log.
  */
-xfs_buf_t *
+struct xfs_buf *
 xlog_get_bp(
 	struct xlog	*log,
 	int		nbblks)
 {
+	struct xfs_buf	*bp;
+
 	if (!xlog_buf_bbcount_valid(log, nbblks)) {
 		xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
 			nbblks);
@@ -67,7 +69,8 @@ xlog_get_bp(
 		nbblks += log->l_sectBBsize;
 	nbblks = round_up(nbblks, log->l_sectBBsize);
 
-	return libxfs_buf_get_uncached(log->l_dev, nbblks, 0);
+	libxfs_buf_get_uncached(log->l_dev, nbblks, 0, &bp);
+	return bp;
 }
 
 /*
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b50b8b3a..e6b44575 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3404,8 +3404,14 @@ get_write_buf(
 	int			bblen)
 {
 	struct xfs_buf		*bp;
+	int			error;
 
-	bp = libxfs_buf_get_uncached(btp, bblen, 0);
+	error = -libxfs_buf_get_uncached(btp, bblen, 0, &bp);
+	if (error) {
+		fprintf(stderr, _("Could not get memory for buffer, err=%d\n"),
+				error);
+		exit(1);
+	}
 	bp->b_bn = daddr;
 	bp->b_maps[0].bm_bn = daddr;
 	return bp;


  parent reply	other threads:[~2020-02-20  1:45 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 ` [PATCH 03/14] libxfs: make libxfs_buf_get_map " Darrick J. Wong
2020-02-21 14:57   ` 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 ` Darrick J. Wong [this message]
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:15 ` [PATCH 08/14] xfs: make xfs_buf_get_uncached 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=158216312194.603628.5152582204376597051.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=hch@lst.de \
    --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.