linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Buffer's log item refactoring
@ 2018-01-19 14:08 Carlos Maiolino
  2018-01-19 14:08 ` [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef Carlos Maiolino
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 14:08 UTC (permalink / raw)
  To: linux-xfs

Hi,

A few time ago Christoph suggested to use list_head API to handle buffer's
log_item_list.

This patchset aims to split the current bp->b_fspriv field into a specific field
to hold the xfs_buf_log_item, and another to hold the list of log items attached
to the buffer (3rd patch), and finally replace the singly linked list
implementation by the list_head infra-structure (4th patch).

The first two patches are just a typedef removal of xfs_buf_log_item_t and
xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
thought since we plan to get rid of the typedefs in future, this might be
useful.

I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
removal patches are useless, you guys call.

This patchset survived several xfstests runs.

Cheers.

Carlos Maiolino (4):
  Get rid of xfs_buf_log_item_t typedef
  Get rid of xfs_buf_t typedef
  Split buffer's b_fspriv field
  Use list_head infra-structure for buffer's log items list

 fs/xfs/libxfs/xfs_alloc.c          |  36 ++++----
 fs/xfs/libxfs/xfs_attr_leaf.c      |   2 +-
 fs/xfs/libxfs/xfs_bmap.c           |   8 +-
 fs/xfs/libxfs/xfs_btree.c          |  26 +++---
 fs/xfs/libxfs/xfs_btree.h          |   2 +-
 fs/xfs/libxfs/xfs_da_btree.c       |   2 +-
 fs/xfs/libxfs/xfs_dir2_block.c     |   2 +-
 fs/xfs/libxfs/xfs_dir2_data.c      |   2 +-
 fs/xfs/libxfs/xfs_dir2_leaf.c      |   2 +-
 fs/xfs/libxfs/xfs_dir2_node.c      |   2 +-
 fs/xfs/libxfs/xfs_ialloc.c         |  18 ++--
 fs/xfs/libxfs/xfs_inode_buf.c      |   4 +-
 fs/xfs/libxfs/xfs_rtbitmap.c       |  22 ++---
 fs/xfs/libxfs/xfs_sb.c             |   2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c |   2 +-
 fs/xfs/xfs_buf.c                   | 140 +++++++++++++++----------------
 fs/xfs/xfs_buf.h                   |  21 ++---
 fs/xfs/xfs_buf_item.c              | 166 ++++++++++++++++++++-----------------
 fs/xfs/xfs_buf_item.h              |   7 +-
 fs/xfs/xfs_dquot.c                 |  22 ++---
 fs/xfs/xfs_dquot_item.c            |   2 +-
 fs/xfs/xfs_fsops.c                 |   2 +-
 fs/xfs/xfs_inode.c                 |  24 +++---
 fs/xfs/xfs_inode_item.c            |  41 +++------
 fs/xfs/xfs_itable.c                |   2 +-
 fs/xfs/xfs_log.c                   |  26 +++---
 fs/xfs/xfs_log_recover.c           |  46 +++++-----
 fs/xfs/xfs_qm.c                    |   8 +-
 fs/xfs/xfs_rtalloc.c               |  20 ++---
 fs/xfs/xfs_rtalloc.h               |   4 +-
 fs/xfs/xfs_symlink.c               |  22 ++---
 fs/xfs/xfs_trans.c                 |   2 +-
 fs/xfs/xfs_trans.h                 |   4 +-
 fs/xfs/xfs_trans_buf.c             | 104 ++++++++++++-----------
 34 files changed, 397 insertions(+), 398 deletions(-)

-- 
2.14.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef
  2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
@ 2018-01-19 14:08 ` Carlos Maiolino
  2018-01-20  3:33   ` Darrick J. Wong
  2018-01-19 14:08 ` [PATCH 2/4] Get rid of xfs_buf_t typedef Carlos Maiolino
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 14:08 UTC (permalink / raw)
  To: linux-xfs

Take advantage of the rework on xfs_buf log items list, to get rid of
ths typedef for xfs_buf_log_item.

This patch also fix some indentation alignment issues found along the way.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/xfs_buf_item.c  | 40 ++++++++++++++++----------------
 fs/xfs/xfs_buf_item.h  |  6 ++---
 fs/xfs/xfs_trans_buf.c | 62 +++++++++++++++++++++++++++-----------------------
 3 files changed, 56 insertions(+), 52 deletions(-)

diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index e0a0af0946f2..8afcfa3ed976 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -61,14 +61,14 @@ xfs_buf_log_format_size(
  */
 STATIC void
 xfs_buf_item_size_segment(
-	struct xfs_buf_log_item	*bip,
-	struct xfs_buf_log_format *blfp,
-	int			*nvecs,
-	int			*nbytes)
+	struct xfs_buf_log_item		*bip,
+	struct xfs_buf_log_format	*blfp,
+	int				*nvecs,
+	int				*nbytes)
 {
-	struct xfs_buf		*bp = bip->bli_buf;
-	int			next_bit;
-	int			last_bit;
+	struct xfs_buf			*bp = bip->bli_buf;
+	int				next_bit;
+	int				last_bit;
 
 	last_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
 	if (last_bit == -1)
@@ -218,12 +218,12 @@ xfs_buf_item_format_segment(
 	uint			offset,
 	struct xfs_buf_log_format *blfp)
 {
-	struct xfs_buf	*bp = bip->bli_buf;
-	uint		base_size;
-	int		first_bit;
-	int		last_bit;
-	int		next_bit;
-	uint		nbits;
+	struct xfs_buf		*bp = bip->bli_buf;
+	uint			base_size;
+	int			first_bit;
+	int			last_bit;
+	int			next_bit;
+	uint			nbits;
 
 	/* copy the flags across from the base format item */
 	blfp->blf_flags = bip->__bli_format.blf_flags;
@@ -406,10 +406,10 @@ xfs_buf_item_unpin(
 	int			remove)
 {
 	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
-	xfs_buf_t	*bp = bip->bli_buf;
-	struct xfs_ail	*ailp = lip->li_ailp;
-	int		stale = bip->bli_flags & XFS_BLI_STALE;
-	int		freed;
+	xfs_buf_t		*bp = bip->bli_buf;
+	struct xfs_ail		*ailp = lip->li_ailp;
+	int			stale = bip->bli_flags & XFS_BLI_STALE;
+	int			freed;
 
 	ASSERT(bp->b_fspriv == bip);
 	ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -880,7 +880,7 @@ xfs_buf_item_log_segment(
  */
 void
 xfs_buf_item_log(
-	xfs_buf_log_item_t	*bip,
+	struct xfs_buf_log_item	*bip,
 	uint			first,
 	uint			last)
 {
@@ -943,7 +943,7 @@ xfs_buf_item_dirty_format(
 
 STATIC void
 xfs_buf_item_free(
-	xfs_buf_log_item_t	*bip)
+	struct xfs_buf_log_item	*bip)
 {
 	xfs_buf_item_free_format(bip);
 	kmem_free(bip->bli_item.li_lv_shadow);
@@ -961,7 +961,7 @@ void
 xfs_buf_item_relse(
 	xfs_buf_t	*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	trace_xfs_buf_item_relse(bp, _RET_IP_);
 	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 9690ce62c9a7..0febfbbf6ba9 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -50,7 +50,7 @@ struct xfs_buf_log_item;
  * needed to log buffers.  It tracks how many times the lock has been
  * locked, and which 128 byte chunks of the buffer are dirty.
  */
-typedef struct xfs_buf_log_item {
+struct xfs_buf_log_item {
 	xfs_log_item_t		bli_item;	/* common item structure */
 	struct xfs_buf		*bli_buf;	/* real buffer pointer */
 	unsigned int		bli_flags;	/* misc flags */
@@ -59,11 +59,11 @@ typedef struct xfs_buf_log_item {
 	int			bli_format_count;	/* count of headers */
 	struct xfs_buf_log_format *bli_formats;	/* array of in-log header ptrs */
 	struct xfs_buf_log_format __bli_format;	/* embedded in-log header */
-} xfs_buf_log_item_t;
+};
 
 int	xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
 void	xfs_buf_item_relse(struct xfs_buf *);
-void	xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
+void	xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
 bool	xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
 void	xfs_buf_attach_iodone(struct xfs_buf *,
 			      void(*)(struct xfs_buf *, xfs_log_item_t *),
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 3ba7a96a8abd..74563cd2970c 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -139,7 +139,7 @@ xfs_trans_get_buf_map(
 	xfs_buf_flags_t		flags)
 {
 	xfs_buf_t		*bp;
-	xfs_buf_log_item_t	*bip;
+	struct xfs_buf_log_item	*bip;
 
 	if (!tp)
 		return xfs_buf_get_map(target, map, nmaps, flags);
@@ -188,12 +188,13 @@ xfs_trans_get_buf_map(
  * mount structure.
  */
 xfs_buf_t *
-xfs_trans_getsb(xfs_trans_t	*tp,
-		struct xfs_mount *mp,
-		int		flags)
+xfs_trans_getsb(
+	xfs_trans_t		*tp,
+	struct xfs_mount	*mp,
+	int			flags)
 {
 	xfs_buf_t		*bp;
-	xfs_buf_log_item_t	*bip;
+	struct xfs_buf_log_item	*bip;
 
 	/*
 	 * Default to just trying to lock the superblock buffer
@@ -352,10 +353,11 @@ xfs_trans_read_buf_map(
  * brelse() call.
  */
 void
-xfs_trans_brelse(xfs_trans_t	*tp,
-		 xfs_buf_t	*bp)
+xfs_trans_brelse(
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip;
+	struct xfs_buf_log_item	*bip;
 	int			freed;
 
 	/*
@@ -456,10 +458,11 @@ xfs_trans_brelse(xfs_trans_t	*tp,
  */
 /* ARGSUSED */
 void
-xfs_trans_bhold(xfs_trans_t	*tp,
-		xfs_buf_t	*bp)
+xfs_trans_bhold(
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -476,10 +479,11 @@ xfs_trans_bhold(xfs_trans_t	*tp,
  * for this transaction.
  */
 void
-xfs_trans_bhold_release(xfs_trans_t	*tp,
-			xfs_buf_t	*bp)
+xfs_trans_bhold_release(
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -600,10 +604,10 @@ xfs_trans_log_buf(
  */
 void
 xfs_trans_binval(
-	xfs_trans_t	*tp,
-	xfs_buf_t	*bp)
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 	int			i;
 
 	ASSERT(bp->b_transp == tp);
@@ -655,10 +659,10 @@ xfs_trans_binval(
  */
 void
 xfs_trans_inode_buf(
-	xfs_trans_t	*tp,
-	xfs_buf_t	*bp)
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -679,10 +683,10 @@ xfs_trans_inode_buf(
  */
 void
 xfs_trans_stale_inode_buf(
-	xfs_trans_t	*tp,
-	xfs_buf_t	*bp)
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -704,10 +708,10 @@ xfs_trans_stale_inode_buf(
 /* ARGSUSED */
 void
 xfs_trans_inode_alloc_buf(
-	xfs_trans_t	*tp,
-	xfs_buf_t	*bp)
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp)
 {
-	xfs_buf_log_item_t	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -797,9 +801,9 @@ xfs_trans_buf_copy_type(
 /* ARGSUSED */
 void
 xfs_trans_dquot_buf(
-	xfs_trans_t	*tp,
-	xfs_buf_t	*bp,
-	uint		type)
+	xfs_trans_t		*tp,
+	xfs_buf_t		*bp,
+	uint			type)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/4] Get rid of xfs_buf_t typedef
  2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
  2018-01-19 14:08 ` [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef Carlos Maiolino
@ 2018-01-19 14:08 ` Carlos Maiolino
  2018-01-20  3:35   ` Darrick J. Wong
  2018-01-19 14:08 ` [PATCH 3/4] Split buffer's b_fspriv field Carlos Maiolino
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 14:08 UTC (permalink / raw)
  To: linux-xfs

Took advantage from my rework on bp->b_fspriv to get rid of the
xfs_buf_t typedef.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c     |  32 +++++-----
 fs/xfs/libxfs/xfs_bmap.c      |   8 +--
 fs/xfs/libxfs/xfs_btree.c     |  22 +++----
 fs/xfs/libxfs/xfs_btree.h     |   2 +-
 fs/xfs/libxfs/xfs_ialloc.c    |  16 ++---
 fs/xfs/libxfs/xfs_inode_buf.c |   4 +-
 fs/xfs/libxfs/xfs_rtbitmap.c  |  22 +++----
 fs/xfs/xfs_buf.c              | 139 +++++++++++++++++++++---------------------
 fs/xfs/xfs_buf.h              |  18 +++---
 fs/xfs/xfs_buf_item.c         |   8 +--
 fs/xfs/xfs_dquot.c            |  22 +++----
 fs/xfs/xfs_fsops.c            |   2 +-
 fs/xfs/xfs_inode.c            |  16 ++---
 fs/xfs/xfs_itable.c           |   2 +-
 fs/xfs/xfs_log.c              |  17 +++---
 fs/xfs/xfs_log_recover.c      |  40 ++++++------
 fs/xfs/xfs_qm.c               |   8 +--
 fs/xfs/xfs_rtalloc.c          |  20 +++---
 fs/xfs/xfs_rtalloc.h          |   4 +-
 fs/xfs/xfs_symlink.c          |  22 +++----
 fs/xfs/xfs_trans.c            |   2 +-
 fs/xfs/xfs_trans.h            |   2 +-
 fs/xfs/xfs_trans_buf.c        |  22 +++----
 23 files changed, 225 insertions(+), 225 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 50ba989481cc..b41999fcbbe0 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -590,7 +590,7 @@ static void
 xfs_agfl_write_verify(
 	struct xfs_buf	*bp)
 {
-	struct xfs_mount *mp = bp->b_target->bt_mount;
+	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 	xfs_failaddr_t		fa;
 
@@ -625,9 +625,9 @@ xfs_alloc_read_agfl(
 	xfs_mount_t	*mp,		/* mount point structure */
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_agnumber_t	agno,		/* allocation group number */
-	xfs_buf_t	**bpp)		/* buffer for the ag free block array */
+	struct xfs_buf	**bpp)		/* buffer for the ag free block array */
 {
-	xfs_buf_t	*bp;		/* return value */
+	struct xfs_buf	*bp;		/* return value */
 	int		error;
 
 	ASSERT(agno != NULLAGNUMBER);
@@ -1594,7 +1594,7 @@ xfs_alloc_ag_vextent_small(
 			      xfs_alloc_allow_busy_reuse(args->datatype));
 
 			if (xfs_alloc_is_userdata(args->datatype)) {
-				xfs_buf_t	*bp;
+				struct xfs_buf	*bp;
 
 				bp = xfs_btree_get_bufs(args->mp, args->tp,
 					args->agno, fbno, 0);
@@ -1670,7 +1670,7 @@ xfs_alloc_ag_vextent_small(
 STATIC int
 xfs_free_ag_extent(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*agbp,
+	struct xfs_buf		*agbp,
 	xfs_agnumber_t		agno,
 	xfs_agblock_t		bno,
 	xfs_extlen_t		len,
@@ -2229,12 +2229,12 @@ xfs_alloc_fix_freelist(
 int				/* error */
 xfs_alloc_get_freelist(
 	xfs_trans_t	*tp,	/* transaction pointer */
-	xfs_buf_t	*agbp,	/* buffer containing the agf structure */
+	struct xfs_buf	*agbp,	/* buffer containing the agf structure */
 	xfs_agblock_t	*bnop,	/* block address retrieved from freelist */
 	int		btreeblk) /* destination is a AGF btree */
 {
 	xfs_agf_t	*agf;	/* a.g. freespace structure */
-	xfs_buf_t	*agflbp;/* buffer for a.g. freelist structure */
+	struct xfs_buf	*agflbp;/* buffer for a.g. freelist structure */
 	xfs_agblock_t	bno;	/* block number returned */
 	__be32		*agfl_bno;
 	int		error;
@@ -2294,7 +2294,7 @@ xfs_alloc_get_freelist(
 void
 xfs_alloc_log_agf(
 	xfs_trans_t	*tp,	/* transaction pointer */
-	xfs_buf_t	*bp,	/* buffer for a.g. freelist header */
+	struct xfs_buf	*bp,	/* buffer for a.g. freelist header */
 	int		fields)	/* mask of fields to be logged (XFS_AGF_...) */
 {
 	int	first;		/* first byte offset */
@@ -2340,7 +2340,7 @@ xfs_alloc_pagf_init(
 	xfs_agnumber_t		agno,	/* allocation group number */
 	int			flags)	/* XFS_ALLOC_FLAGS_... */
 {
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			error;
 
 	if ((error = xfs_alloc_read_agf(mp, tp, agno, flags, &bp)))
@@ -2356,8 +2356,8 @@ xfs_alloc_pagf_init(
 int					/* error */
 xfs_alloc_put_freelist(
 	xfs_trans_t		*tp,	/* transaction pointer */
-	xfs_buf_t		*agbp,	/* buffer for a.g. freelist header */
-	xfs_buf_t		*agflbp,/* buffer for a.g. free block array */
+	struct xfs_buf		*agbp,	/* buffer for a.g. freelist header */
+	struct xfs_buf		*agflbp,/* buffer for a.g. free block array */
 	xfs_agblock_t		bno,	/* block being freed */
 	int			btreeblk) /* block came from a AGF btree */
 {
@@ -2468,10 +2468,10 @@ xfs_agf_verify(
 
 static void
 xfs_agf_read_verify(
-	struct xfs_buf	*bp)
+	struct xfs_buf		*bp)
 {
-	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
+	struct xfs_mount	*mp = bp->b_target->bt_mount;
+	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
@@ -2485,9 +2485,9 @@ xfs_agf_read_verify(
 
 static void
 xfs_agf_write_verify(
-	struct xfs_buf	*bp)
+	struct xfs_buf		*bp)
 {
-	struct xfs_mount *mp = bp->b_target->bt_mount;
+	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 140744700b07..651eb4639713 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -334,7 +334,7 @@ xfs_bmap_check_leaf_extents(
 {
 	struct xfs_btree_block	*block;	/* current btree block */
 	xfs_fsblock_t		bno;	/* block # of "block" */
-	xfs_buf_t		*bp;	/* buffer for "block" */
+	struct xfs_buf		*bp;	/* buffer for "block" */
 	int			error;	/* error return value */
 	xfs_extnum_t		i=0, j;	/* index into the extents list */
 	xfs_ifork_t		*ifp;	/* fork structure */
@@ -600,7 +600,7 @@ xfs_bmap_btree_to_extents(
 	/* REFERENCED */
 	struct xfs_btree_block	*cblock;/* child btree block */
 	xfs_fsblock_t		cbno;	/* child block number */
-	xfs_buf_t		*cbp;	/* child block's buffer */
+	struct xfs_buf		*cbp;	/* child block's buffer */
 	int			error;	/* error return value */
 	xfs_ifork_t		*ifp;	/* inode fork data */
 	xfs_mount_t		*mp;	/* mount point structure */
@@ -662,7 +662,7 @@ xfs_bmap_extents_to_btree(
 	int			whichfork)	/* data or attr fork */
 {
 	struct xfs_btree_block	*ablock;	/* allocated (child) bt block */
-	xfs_buf_t		*abp;		/* buffer for ablock */
+	struct xfs_buf		*abp;		/* buffer for ablock */
 	xfs_alloc_arg_t		args;		/* allocation arguments */
 	xfs_bmbt_rec_t		*arp;		/* child record pointer */
 	struct xfs_btree_block	*block;		/* btree root block */
@@ -829,7 +829,7 @@ xfs_bmap_local_to_extents(
 	int		flags;		/* logging flags returned */
 	xfs_ifork_t	*ifp;		/* inode fork pointer */
 	xfs_alloc_arg_t	args;		/* allocation arguments */
-	xfs_buf_t	*bp;		/* buffer for extent block */
+	struct xfs_buf	*bp;		/* buffer for extent block */
 	struct xfs_bmbt_irec rec;
 	struct xfs_iext_cursor icur;
 
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 2b2be1d6c00d..cc501b7d1fc5 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -398,7 +398,7 @@ xfs_btree_dup_cursor(
 	xfs_btree_cur_t	*cur,		/* input cursor */
 	xfs_btree_cur_t	**ncur)		/* output cursor */
 {
-	xfs_buf_t	*bp;		/* btree block's buffer pointer */
+	struct xfs_buf	*bp;		/* btree block's buffer pointer */
 	int		error;		/* error return value */
 	int		i;		/* level number of btree block */
 	xfs_mount_t	*mp;		/* mount structure for filesystem */
@@ -686,14 +686,14 @@ xfs_btree_get_block(
  * Get a buffer for the block, return it with no data read.
  * Long-form addressing.
  */
-xfs_buf_t *				/* buffer for fsbno */
+struct xfs_buf *			/* buffer for fsbno */
 xfs_btree_get_bufl(
 	xfs_mount_t	*mp,		/* file system mount point */
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_fsblock_t	fsbno,		/* file system block number */
 	uint		lock)		/* lock flags for get_buf */
 {
-	xfs_daddr_t		d;		/* real disk block address */
+	xfs_daddr_t	d;		/* real disk block address */
 
 	ASSERT(fsbno != NULLFSBLOCK);
 	d = XFS_FSB_TO_DADDR(mp, fsbno);
@@ -704,7 +704,7 @@ xfs_btree_get_bufl(
  * Get a buffer for the block, return it with no data read.
  * Short-form addressing.
  */
-xfs_buf_t *				/* buffer for agno/agbno */
+struct xfs_buf *			/* buffer for agno/agbno */
 xfs_btree_get_bufs(
 	xfs_mount_t	*mp,		/* file system mount point */
 	xfs_trans_t	*tp,		/* transaction pointer */
@@ -712,7 +712,7 @@ xfs_btree_get_bufs(
 	xfs_agblock_t	agbno,		/* allocation group block number */
 	uint		lock)		/* lock flags for get_buf */
 {
-	xfs_daddr_t		d;		/* real disk block address */
+	xfs_daddr_t	d;		/* real disk block address */
 
 	ASSERT(agno != NULLAGNUMBER);
 	ASSERT(agbno != NULLAGBLOCK);
@@ -729,7 +729,7 @@ xfs_btree_islastblock(
 	int			level)	/* level to check */
 {
 	struct xfs_btree_block	*block;	/* generic btree block pointer */
-	xfs_buf_t		*bp;	/* buffer containing block */
+	struct xfs_buf		*bp;	/* buffer containing block */
 
 	block = xfs_btree_get_block(cur, level, &bp);
 	xfs_btree_check_block(cur, block, level, bp);
@@ -749,7 +749,7 @@ xfs_btree_firstrec(
 	int			level)	/* level to change */
 {
 	struct xfs_btree_block	*block;	/* generic btree block pointer */
-	xfs_buf_t		*bp;	/* buffer containing block */
+	struct xfs_buf		*bp;	/* buffer containing block */
 
 	/*
 	 * Get the block pointer for this level.
@@ -779,7 +779,7 @@ xfs_btree_lastrec(
 	int			level)	/* level to change */
 {
 	struct xfs_btree_block	*block;	/* generic btree block pointer */
-	xfs_buf_t		*bp;	/* buffer containing block */
+	struct xfs_buf		*bp;	/* buffer containing block */
 
 	/*
 	 * Get the block pointer for this level.
@@ -1031,7 +1031,7 @@ STATIC void
 xfs_btree_setbuf(
 	xfs_btree_cur_t		*cur,	/* btree cursor */
 	int			lev,	/* level in btree */
-	xfs_buf_t		*bp)	/* new buffer to set */
+	struct xfs_buf		*bp)	/* new buffer to set */
 {
 	struct xfs_btree_block	*b;	/* btree block */
 
@@ -1696,7 +1696,7 @@ xfs_btree_decrement(
 	int			*stat)		/* success/failure */
 {
 	struct xfs_btree_block	*block;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			error;		/* error return value */
 	int			lev;
 	union xfs_btree_ptr	ptr;
@@ -3230,7 +3230,7 @@ xfs_btree_make_block_unfull(
 
 	if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) &&
 	    level == cur->bc_nlevels - 1) {
-	    	struct xfs_inode *ip = cur->bc_private.b.ip;
+		struct xfs_inode *ip = cur->bc_private.b.ip;
 
 		if (numrecs < cur->bc_ops->get_dmaxrecs(cur, level)) {
 			/* A root block that can be made bigger. */
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index 2f13b8676f41..31df5935d6ab 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -478,7 +478,7 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
  * over to the generic tracing functionality, which is some effort.
  *
  * i,j = integer (32 bit)
- * b = btree block buffer (xfs_buf_t)
+ * b = btree block buffer (struct xfs_buf)
  * p = btree ptr
  * r = btree record
  * k = btree key
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index c01ed9cfc5ae..1580912fe5a2 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -604,7 +604,7 @@ xfs_inobt_insert_sprec(
 STATIC int				/* error code or 0 */
 xfs_ialloc_ag_alloc(
 	xfs_trans_t	*tp,		/* transaction pointer */
-	xfs_buf_t	*agbp,		/* alloc group buffer */
+	struct xfs_buf	*agbp,		/* alloc group buffer */
 	int		*alloc)
 {
 	xfs_agi_t	*agi;		/* allocation group header */
@@ -2127,9 +2127,9 @@ xfs_difree_finobt(
  */
 int
 xfs_difree(
-	struct xfs_trans	*tp,		/* transaction pointer */
-	xfs_ino_t		inode,		/* inode to be freed */
-	struct xfs_defer_ops	*dfops,		/* extents to free */
+	struct xfs_trans	*tp,	/* transaction pointer */
+	xfs_ino_t		inode,	/* inode to be freed */
+	struct xfs_defer_ops	*dfops,	/* extents to free */
 	struct xfs_icluster	*xic)	/* cluster info if deleted */
 {
 	/* REFERENCED */
@@ -2425,7 +2425,7 @@ xfs_ialloc_compute_maxlevels(
 void
 xfs_ialloc_log_agi(
 	xfs_trans_t	*tp,		/* transaction pointer */
-	xfs_buf_t	*bp,		/* allocation group header buffer */
+	struct xfs_buf	*bp,		/* allocation group header buffer */
 	int		fields)		/* bitmask of fields to log */
 {
 	int			first;		/* first byte number */
@@ -2555,9 +2555,9 @@ xfs_agi_read_verify(
 
 static void
 xfs_agi_write_verify(
-	struct xfs_buf	*bp)
+	struct xfs_buf		*bp)
 {
-	struct xfs_mount *mp = bp->b_target->bt_mount;
+	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 	xfs_failaddr_t		fa;
 
@@ -2653,7 +2653,7 @@ xfs_ialloc_pagi_init(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_agnumber_t	agno)		/* allocation group number */
 {
-	xfs_buf_t	*bp = NULL;
+	struct xfs_buf	*bp = NULL;
 	int		error;
 
 	error = xfs_ialloc_read_agi(mp, tp, agno, &bp);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 4035b5d5f6fd..ae1f58e19e49 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -40,7 +40,7 @@
 void
 xfs_inobp_check(
 	xfs_mount_t	*mp,
-	xfs_buf_t	*bp)
+	struct xfs_buf	*bp)
 {
 	int		i;
 	int		j;
@@ -542,7 +542,7 @@ xfs_iread(
 	xfs_inode_t	*ip,
 	uint		iget_flags)
 {
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	xfs_dinode_t	*dip;
 	xfs_failaddr_t	fa;
 	int		error;
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index 3fb29a5ea915..f6b94eb191c8 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -76,9 +76,9 @@ xfs_rtbuf_get(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_rtblock_t	block,		/* block number in bitmap or summary */
 	int		issum,		/* is summary not bitmap */
-	xfs_buf_t	**bpp)		/* output: buffer for the block */
+	struct xfs_buf	**bpp)		/* output: buffer for the block */
 {
-	xfs_buf_t	*bp;		/* block buffer, result */
+	struct xfs_buf	*bp;		/* block buffer, result */
 	xfs_inode_t	*ip;		/* bitmap or summary inode */
 	xfs_bmbt_irec_t	map;
 	int		nmap = 1;
@@ -118,7 +118,7 @@ xfs_rtfind_back(
 	xfs_rtword_t	*b;		/* current word in buffer */
 	int		bit;		/* bit number in the word */
 	xfs_rtblock_t	block;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* buf for the block */
+	struct xfs_buf	*bp;		/* buf for the block */
 	xfs_rtword_t	*bufp;		/* starting word in buffer */
 	int		error;		/* error value */
 	xfs_rtblock_t	firstbit;	/* first useful bit in the word */
@@ -293,7 +293,7 @@ xfs_rtfind_forw(
 	xfs_rtword_t	*b;		/* current word in buffer */
 	int		bit;		/* bit number in the word */
 	xfs_rtblock_t	block;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* buf for the block */
+	struct xfs_buf	*bp;		/* buf for the block */
 	xfs_rtword_t	*bufp;		/* starting word in buffer */
 	int		error;		/* error value */
 	xfs_rtblock_t	i;		/* current bit number rel. to start */
@@ -464,11 +464,11 @@ xfs_rtmodify_summary_int(
 	int		log,		/* log2 of extent size */
 	xfs_rtblock_t	bbno,		/* bitmap block number */
 	int		delta,		/* change to make to summary info */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_suminfo_t	*sum)		/* out: summary info for this block */
 {
-	xfs_buf_t	*bp;		/* buffer for the summary block */
+	struct xfs_buf	*bp;		/* buffer for the summary block */
 	int		error;		/* error value */
 	xfs_fsblock_t	sb;		/* summary fsblock */
 	int		so;		/* index into the summary file */
@@ -528,7 +528,7 @@ xfs_rtmodify_summary(
 	int		log,		/* log2 of extent size */
 	xfs_rtblock_t	bbno,		/* bitmap block number */
 	int		delta,		/* change to make to summary info */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
 {
 	return xfs_rtmodify_summary_int(mp, tp, log, bbno,
@@ -550,7 +550,7 @@ xfs_rtmodify_range(
 	xfs_rtword_t	*b;		/* current word in buffer */
 	int		bit;		/* bit number in the word */
 	xfs_rtblock_t	block;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* buf for the block */
+	struct xfs_buf	*bp;		/* buf for the block */
 	xfs_rtword_t	*bufp;		/* starting word in buffer */
 	int		error;		/* error value */
 	xfs_rtword_t	*first;		/* first used word in the buffer */
@@ -701,7 +701,7 @@ xfs_rtfree_range(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_rtblock_t	start,		/* starting block to free */
 	xfs_extlen_t	len,		/* length to free */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
 {
 	xfs_rtblock_t	end;		/* end of the freed extent */
@@ -784,7 +784,7 @@ xfs_rtcheck_range(
 	xfs_rtword_t	*b;		/* current word in buffer */
 	int		bit;		/* bit number in the word */
 	xfs_rtblock_t	block;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* buf for the block */
+	struct xfs_buf	*bp;		/* buf for the block */
 	xfs_rtword_t	*bufp;		/* starting word in buffer */
 	int		error;		/* error value */
 	xfs_rtblock_t	i;		/* current bit number rel. to start */
@@ -980,7 +980,7 @@ xfs_rtfree_extent(
 	int		error;		/* error value */
 	xfs_mount_t	*mp;		/* file system mount structure */
 	xfs_fsblock_t	sb;		/* summary file block number */
-	xfs_buf_t	*sumbp = NULL;	/* summary file block buffer */
+	struct xfs_buf	*sumbp = NULL;	/* summary file block buffer */
 
 	mp = tp->t_mountp;
 
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 1981ef77040d..07dccb05e782 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -179,8 +179,8 @@ xfs_buf_stale(
 
 static int
 xfs_buf_get_maps(
-	struct xfs_buf		*bp,
-	int			map_count)
+	struct xfs_buf	*bp,
+	int		map_count)
 {
 	ASSERT(bp->b_maps == NULL);
 	bp->b_map_count = map_count;
@@ -277,8 +277,8 @@ _xfs_buf_alloc(
  */
 STATIC int
 _xfs_buf_get_pages(
-	xfs_buf_t		*bp,
-	int			page_count)
+	struct xfs_buf	*bp,
+	int		page_count)
 {
 	/* Make sure that we have a page list */
 	if (bp->b_pages == NULL) {
@@ -301,7 +301,7 @@ _xfs_buf_get_pages(
  */
 STATIC void
 _xfs_buf_free_pages(
-	xfs_buf_t	*bp)
+	struct xfs_buf	*bp)
 {
 	if (bp->b_pages != bp->b_page_array) {
 		kmem_free(bp->b_pages);
@@ -312,13 +312,13 @@ _xfs_buf_free_pages(
 /*
  *	Releases the specified buffer.
  *
- * 	The modification state of any associated pages is left unchanged.
- * 	The buffer must not be on any hash - use xfs_buf_rele instead for
- * 	hashed and refcounted buffers
+ *	The modification state of any associated pages is left unchanged.
+ *	The buffer must not be on any hash - use xfs_buf_rele instead for
+ *	hashed and refcounted buffers
  */
 void
 xfs_buf_free(
-	xfs_buf_t		*bp)
+	struct xfs_buf	*bp)
 {
 	trace_xfs_buf_free(bp, _RET_IP_);
 
@@ -348,15 +348,15 @@ xfs_buf_free(
  */
 STATIC int
 xfs_buf_allocate_memory(
-	xfs_buf_t		*bp,
-	uint			flags)
-{
-	size_t			size;
-	size_t			nbytes, offset;
-	gfp_t			gfp_mask = xb_to_gfp(flags);
-	unsigned short		page_count, i;
-	xfs_off_t		start, end;
-	int			error;
+	struct xfs_buf	*bp,
+	uint		flags)
+{
+	size_t		size;
+	size_t		nbytes, offset;
+	gfp_t		gfp_mask = xb_to_gfp(flags);
+	unsigned short	page_count, i;
+	xfs_off_t	start, end;
+	int		error;
 
 	/*
 	 * for buffers that are contained within a single page, just allocate
@@ -448,8 +448,8 @@ xfs_buf_allocate_memory(
  */
 STATIC int
 _xfs_buf_map_pages(
-	xfs_buf_t		*bp,
-	uint			flags)
+	struct xfs_buf	*bp,
+	uint		flags)
 {
 	ASSERT(bp->b_flags & _XBF_PAGES);
 	if (bp->b_page_count == 1) {
@@ -552,16 +552,16 @@ xfs_buf_hash_destroy(
  *	a given range of an inode.  The buffer is returned
  *	locked.	No I/O is implied by this call.
  */
-xfs_buf_t *
+struct xfs_buf *
 _xfs_buf_find(
 	struct xfs_buftarg	*btp,
 	struct xfs_buf_map	*map,
 	int			nmaps,
 	xfs_buf_flags_t		flags,
-	xfs_buf_t		*new_bp)
+	struct xfs_buf		*new_bp)
 {
 	struct xfs_perag	*pag;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	struct xfs_buf_map	cmap = { .bm_bn = map[0].bm_bn };
 	xfs_daddr_t		eofs;
 	int			i;
@@ -712,8 +712,8 @@ xfs_buf_get_map(
 
 STATIC int
 _xfs_buf_read(
-	xfs_buf_t		*bp,
-	xfs_buf_flags_t		flags)
+	struct xfs_buf	*bp,
+	xfs_buf_flags_t	flags)
 {
 	ASSERT(!(flags & XBF_WRITE));
 	ASSERT(bp->b_maps[0].bm_bn != XFS_BUF_DADDR_NULL);
@@ -728,7 +728,7 @@ _xfs_buf_read(
 	return xfs_buf_submit_wait(bp);
 }
 
-xfs_buf_t *
+struct xfs_buf *
 xfs_buf_read_map(
 	struct xfs_buftarg	*target,
 	struct xfs_buf_map	*map,
@@ -827,8 +827,8 @@ xfs_buf_read_uncached(
  */
 void
 xfs_buf_set_empty(
-	struct xfs_buf		*bp,
-	size_t			numblks)
+	struct xfs_buf	*bp,
+	size_t		numblks)
 {
 	if (bp->b_pages)
 		_xfs_buf_free_pages(bp);
@@ -858,16 +858,16 @@ mem_to_page(
 
 int
 xfs_buf_associate_memory(
-	xfs_buf_t		*bp,
-	void			*mem,
-	size_t			len)
+	struct xfs_buf	*bp,
+	void		*mem,
+	size_t		len)
 {
-	int			rval;
-	int			i = 0;
-	unsigned long		pageaddr;
-	unsigned long		offset;
-	size_t			buflen;
-	int			page_count;
+	int		rval;
+	int		i = 0;
+	unsigned long	pageaddr;
+	unsigned long	offset;
+	size_t		buflen;
+	int		page_count;
 
 	pageaddr = (unsigned long)mem & PAGE_MASK;
 	offset = (unsigned long)mem - pageaddr;
@@ -898,7 +898,7 @@ xfs_buf_associate_memory(
 	return 0;
 }
 
-xfs_buf_t *
+struct xfs_buf *
 xfs_buf_get_uncached(
 	struct xfs_buftarg	*target,
 	size_t			numblks,
@@ -954,7 +954,7 @@ xfs_buf_get_uncached(
  */
 void
 xfs_buf_hold(
-	xfs_buf_t		*bp)
+	struct xfs_buf	*bp)
 {
 	trace_xfs_buf_hold(bp, _RET_IP_);
 	atomic_inc(&bp->b_hold);
@@ -966,7 +966,7 @@ xfs_buf_hold(
  */
 void
 xfs_buf_rele(
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_perag	*pag = bp->b_pag;
 	bool			release;
@@ -1054,9 +1054,9 @@ xfs_buf_rele(
  */
 int
 xfs_buf_trylock(
-	struct xfs_buf		*bp)
+	struct xfs_buf	*bp)
 {
-	int			locked;
+	int		locked;
 
 	locked = down_trylock(&bp->b_sema) == 0;
 	if (locked) {
@@ -1079,7 +1079,7 @@ xfs_buf_trylock(
  */
 void
 xfs_buf_lock(
-	struct xfs_buf		*bp)
+	struct xfs_buf	*bp)
 {
 	trace_xfs_buf_lock(bp, _RET_IP_);
 
@@ -1093,7 +1093,7 @@ xfs_buf_lock(
 
 void
 xfs_buf_unlock(
-	struct xfs_buf		*bp)
+	struct xfs_buf	*bp)
 {
 	ASSERT(xfs_buf_islocked(bp));
 
@@ -1105,7 +1105,7 @@ xfs_buf_unlock(
 
 STATIC void
 xfs_buf_wait_unpin(
-	xfs_buf_t		*bp)
+	struct xfs_buf	*bp)
 {
 	DECLARE_WAITQUEUE	(wait, current);
 
@@ -1165,8 +1165,7 @@ static void
 xfs_buf_ioend_work(
 	struct work_struct	*work)
 {
-	struct xfs_buf		*bp =
-		container_of(work, xfs_buf_t, b_ioend_work);
+	struct xfs_buf	*bp = container_of(work, struct xfs_buf, b_ioend_work);
 
 	xfs_buf_ioend(bp);
 }
@@ -1181,9 +1180,9 @@ xfs_buf_ioend_async(
 
 void
 __xfs_buf_ioerror(
-	xfs_buf_t		*bp,
-	int			error,
-	xfs_failaddr_t		failaddr)
+	struct xfs_buf	*bp,
+	int		error,
+	xfs_failaddr_t	failaddr)
 {
 	ASSERT(error <= 0 && error >= -1000);
 	bp->b_error = error;
@@ -1192,8 +1191,8 @@ __xfs_buf_ioerror(
 
 void
 xfs_buf_ioerror_alert(
-	struct xfs_buf		*bp,
-	const char		*func)
+	struct xfs_buf	*bp,
+	const char	*func)
 {
 	xfs_alert(bp->b_target->bt_mount,
 "metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
@@ -1202,9 +1201,9 @@ xfs_buf_ioerror_alert(
 
 int
 xfs_bwrite(
-	struct xfs_buf		*bp)
+	struct xfs_buf	*bp)
 {
-	int			error;
+	int		error;
 
 	ASSERT(xfs_buf_islocked(bp));
 
@@ -1222,9 +1221,9 @@ xfs_bwrite(
 
 static void
 xfs_buf_bio_end_io(
-	struct bio		*bio)
+	struct bio	*bio)
 {
-	struct xfs_buf		*bp = (struct xfs_buf *)bio->bi_private;
+	struct xfs_buf	*bp = (struct xfs_buf *)bio->bi_private;
 
 	/*
 	 * don't overwrite existing errors - otherwise we can lose errors on
@@ -1545,10 +1544,10 @@ xfs_buf_submit_wait(
 
 void *
 xfs_buf_offset(
-	struct xfs_buf		*bp,
-	size_t			offset)
+	struct xfs_buf	*bp,
+	size_t		offset)
 {
-	struct page		*page;
+	struct page	*page;
 
 	if (bp->b_addr)
 		return bp->b_addr + offset;
@@ -1563,13 +1562,13 @@ xfs_buf_offset(
  */
 void
 xfs_buf_iomove(
-	xfs_buf_t		*bp,	/* buffer to process		*/
-	size_t			boff,	/* starting buffer offset	*/
-	size_t			bsize,	/* length to copy		*/
-	void			*data,	/* data address			*/
-	xfs_buf_rw_t		mode)	/* read/write/zero flag		*/
+	struct xfs_buf	*bp,	/* buffer to process		*/
+	size_t		boff,	/* starting buffer offset	*/
+	size_t		bsize,	/* length to copy		*/
+	void		*data,	/* data address			*/
+	xfs_buf_rw_t	mode)	/* read/write/zero flag		*/
 {
-	size_t			bend;
+	size_t		bend;
 
 	bend = boff + bsize;
 	while (boff < bend) {
@@ -1731,7 +1730,7 @@ xfs_buftarg_shrink_scan(
 				     xfs_buftarg_isolate, &dispose);
 
 	while (!list_empty(&dispose)) {
-		struct xfs_buf *bp;
+		struct xfs_buf	*bp;
 		bp = list_first_entry(&dispose, struct xfs_buf, b_lru);
 		list_del_init(&bp->b_lru);
 		xfs_buf_rele(bp);
@@ -1767,8 +1766,8 @@ xfs_free_buftarg(
 
 int
 xfs_setsize_buftarg(
-	xfs_buftarg_t		*btp,
-	unsigned int		sectorsize)
+	xfs_buftarg_t	*btp,
+	unsigned int	sectorsize)
 {
 	/* Set up metadata sector size info */
 	btp->bt_meta_sectorsize = sectorsize;
@@ -1925,7 +1924,7 @@ xfs_buf_cmp(
 {
 	struct xfs_buf	*ap = container_of(a, struct xfs_buf, b_list);
 	struct xfs_buf	*bp = container_of(b, struct xfs_buf, b_list);
-	xfs_daddr_t		diff;
+	xfs_daddr_t	diff;
 
 	diff = ap->b_maps[0].bm_bn - bp->b_maps[0].bm_bn;
 	if (diff < 0)
@@ -2122,7 +2121,7 @@ xfs_buf_delwri_pushbuf(
 int __init
 xfs_buf_init(void)
 {
-	xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
+	xfs_buf_zone = kmem_zone_init_flags(sizeof(struct xfs_buf), "xfs_buf",
 						KM_ZONE_HWALIGN, NULL);
 	if (!xfs_buf_zone)
 		goto out;
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 5b5b4861c729..90f09e89cda2 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -143,7 +143,7 @@ struct xfs_buf_ops {
 	xfs_failaddr_t (*verify_struct)(struct xfs_buf *bp);
 };
 
-typedef struct xfs_buf {
+struct xfs_buf {
 	/*
 	 * first cacheline holds all the fields needed for an uncontended cache
 	 * hit to be fully processed. The semaphore straddles the cacheline
@@ -214,7 +214,7 @@ typedef struct xfs_buf {
 #ifdef XFS_BUF_LOCK_TRACKING
 	int			b_last_holder;
 #endif
-} xfs_buf_t;
+};
 
 /* Finding and Reading Buffers */
 struct xfs_buf *_xfs_buf_find(struct xfs_buftarg *target,
@@ -303,13 +303,13 @@ int xfs_buf_read_uncached(struct xfs_buftarg *target, xfs_daddr_t daddr,
 void xfs_buf_hold(struct xfs_buf *bp);
 
 /* Releasing Buffers */
-extern void xfs_buf_free(xfs_buf_t *);
-extern void xfs_buf_rele(xfs_buf_t *);
+extern void xfs_buf_free(struct xfs_buf *);
+extern void xfs_buf_rele(struct xfs_buf *);
 
 /* Locking and Unlocking Buffers */
-extern int xfs_buf_trylock(xfs_buf_t *);
-extern void xfs_buf_lock(xfs_buf_t *);
-extern void xfs_buf_unlock(xfs_buf_t *);
+extern int xfs_buf_trylock(struct xfs_buf *);
+extern void xfs_buf_lock(struct xfs_buf *);
+extern void xfs_buf_unlock(struct xfs_buf *);
 #define xfs_buf_islocked(bp) \
 	((bp)->b_sema.count <= 0)
 
@@ -322,7 +322,7 @@ extern void __xfs_buf_ioerror(struct xfs_buf *bp, int error,
 extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);
 extern void xfs_buf_submit(struct xfs_buf *bp);
 extern int xfs_buf_submit_wait(struct xfs_buf *bp);
-extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
+extern void xfs_buf_iomove(struct xfs_buf *, size_t, size_t, void *,
 				xfs_buf_rw_t);
 #define xfs_buf_zero(bp, off, len) \
 	    xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO)
@@ -362,7 +362,7 @@ static inline int xfs_buf_ispinned(struct xfs_buf *bp)
 	return atomic_read(&bp->b_pin_count);
 }
 
-static inline void xfs_buf_relse(xfs_buf_t *bp)
+static inline void xfs_buf_relse(struct xfs_buf *bp)
 {
 	xfs_buf_unlock(bp);
 	xfs_buf_rele(bp);
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 8afcfa3ed976..977a2ccc32f3 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -406,7 +406,7 @@ xfs_buf_item_unpin(
 	int			remove)
 {
 	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
-	xfs_buf_t		*bp = bip->bli_buf;
+	struct xfs_buf		*bp = bip->bli_buf;
 	struct xfs_ail		*ailp = lip->li_ailp;
 	int			stale = bip->bli_flags & XFS_BLI_STALE;
 	int			freed;
@@ -959,7 +959,7 @@ xfs_buf_item_free(
  */
 void
 xfs_buf_item_relse(
-	xfs_buf_t	*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -986,8 +986,8 @@ xfs_buf_item_relse(
  */
 void
 xfs_buf_attach_iodone(
-	xfs_buf_t	*bp,
-	void		(*cb)(xfs_buf_t *, xfs_log_item_t *),
+	struct xfs_buf	*bp,
+	void		(*cb)(struct xfs_buf *, xfs_log_item_t *),
 	xfs_log_item_t	*lip)
 {
 	xfs_log_item_t	*head_lip;
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 43572f8a1b8e..a891d67bcbc9 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -221,16 +221,16 @@ xfs_qm_adjust_dqtimers(
  */
 STATIC void
 xfs_qm_init_dquot_blk(
-	xfs_trans_t	*tp,
-	xfs_mount_t	*mp,
-	xfs_dqid_t	id,
-	uint		type,
-	xfs_buf_t	*bp)
+	xfs_trans_t		*tp,
+	xfs_mount_t		*mp,
+	xfs_dqid_t		id,
+	uint			type,
+	struct xfs_buf		*bp)
 {
 	struct xfs_quotainfo	*q = mp->m_quotainfo;
-	xfs_dqblk_t	*d;
-	xfs_dqid_t	curid;
-	int		i;
+	xfs_dqblk_t		*d;
+	xfs_dqid_t		curid;
+	int			i;
 
 	ASSERT(tp);
 	ASSERT(xfs_buf_islocked(bp));
@@ -298,13 +298,13 @@ xfs_qm_dqalloc(
 	xfs_dquot_t	*dqp,
 	xfs_inode_t	*quotip,
 	xfs_fileoff_t	offset_fsb,
-	xfs_buf_t	**O_bpp)
+	struct xfs_buf	**O_bpp)
 {
 	xfs_fsblock_t	firstblock;
 	struct xfs_defer_ops dfops;
 	xfs_bmbt_irec_t map;
 	int		nmaps, error;
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	xfs_trans_t	*tp = *tpp;
 
 	ASSERT(tp != NULL);
@@ -409,7 +409,7 @@ xfs_qm_dqtobp(
 	xfs_trans_t		**tpp,
 	xfs_dquot_t		*dqp,
 	xfs_disk_dquot_t	**O_ddpp,
-	xfs_buf_t		**O_bpp,
+	struct xfs_buf		**O_bpp,
 	uint			flags)
 {
 	struct xfs_bmbt_irec	map;
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 84d73835c614..37b7dcba5918 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -83,7 +83,7 @@ xfs_growfs_data_private(
 	xfs_extlen_t		agsize;
 	xfs_extlen_t		tmpsize;
 	xfs_alloc_rec_t		*arec;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			bucket;
 	int			dpct;
 	int			error, saved_error = 0;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 663b546f2bcd..54277beb2a3d 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -749,7 +749,7 @@ xfs_ialloc(
 	xfs_nlink_t	nlink,
 	dev_t		rdev,
 	prid_t		prid,
-	xfs_buf_t	**ialloc_context,
+	struct xfs_buf	**ialloc_context,
 	xfs_inode_t	**ipp)
 {
 	struct xfs_mount *mp = tp->t_mountp;
@@ -963,7 +963,7 @@ xfs_dir_ialloc(
 {
 	xfs_trans_t	*tp;
 	xfs_inode_t	*ip;
-	xfs_buf_t	*ialloc_context = NULL;
+	struct xfs_buf	*ialloc_context = NULL;
 	int		code;
 	void		*dqinfo;
 	uint		tflags;
@@ -1954,8 +1954,8 @@ xfs_iunlink(
 	xfs_mount_t	*mp = tp->t_mountp;
 	xfs_agi_t	*agi;
 	xfs_dinode_t	*dip;
-	xfs_buf_t	*agibp;
-	xfs_buf_t	*ibp;
+	struct xfs_buf	*agibp;
+	struct xfs_buf	*ibp;
 	xfs_agino_t	agino;
 	short		bucket_index;
 	int		offset;
@@ -2032,12 +2032,12 @@ xfs_iunlink_remove(
 	xfs_mount_t	*mp;
 	xfs_agi_t	*agi;
 	xfs_dinode_t	*dip;
-	xfs_buf_t	*agibp;
-	xfs_buf_t	*ibp;
+	struct xfs_buf	*agibp;
+	struct xfs_buf	*ibp;
 	xfs_agnumber_t	agno;
 	xfs_agino_t	agino;
 	xfs_agino_t	next_agino;
-	xfs_buf_t	*last_ibp;
+	struct xfs_buf	*last_ibp;
 	xfs_dinode_t	*last_dip = NULL;
 	short		bucket_index;
 	int		offset, last_offset = 0;
@@ -2211,7 +2211,7 @@ xfs_ifree_cluster(
 	int			i, j;
 	int			ioffset;
 	xfs_daddr_t		blkno;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	xfs_inode_t		*ip;
 	xfs_inode_log_item_t	*iip;
 	xfs_log_item_t		*lip;
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index d58310514423..cf0bab028e19 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -346,7 +346,7 @@ xfs_bulkstat(
 	char			__user *ubuffer, /* buffer with inode stats */
 	int			*done)	/* 1 if there are more stats to get */
 {
-	xfs_buf_t		*agbp;	/* agi header buffer */
+	struct xfs_buf		*agbp;	/* agi header buffer */
 	xfs_agino_t		agino;	/* inode # in allocation group */
 	xfs_agnumber_t		agno;	/* allocation group number */
 	xfs_btree_cur_t		*cur;	/* btree cursor for ialloc btree */
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 047df85528b0..3df424328ae3 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1240,7 +1240,8 @@ xlog_space_left(
  * happens with the buffer after the write completes.
  */
 static void
-xlog_iodone(xfs_buf_t *bp)
+xlog_iodone(
+	struct xfs_buf		*bp)
 {
 	struct xlog_in_core	*iclog = bp->b_fspriv;
 	struct xlog		*l = iclog->ic_log;
@@ -1411,7 +1412,7 @@ xlog_alloc_log(
 	xlog_rec_header_t	*head;
 	xlog_in_core_t		**iclogp;
 	xlog_in_core_t		*iclog, *prev_iclog=NULL;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			i;
 	int			error = -ENOMEM;
 	uint			log2_size = 0;
@@ -1823,7 +1824,7 @@ xlog_sync(
 	struct xlog		*log,
 	struct xlog_in_core	*iclog)
 {
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	int		i;
 	uint		count;		/* byte count of bwrite */
 	uint		count_init;	/* initial count before roundup */
@@ -1848,10 +1849,10 @@ xlog_sync(
 	}
 	roundoff = count - count_init;
 	ASSERT(roundoff >= 0);
-	ASSERT((v2 && log->l_mp->m_sb.sb_logsunit > 1 && 
+	ASSERT((v2 && log->l_mp->m_sb.sb_logsunit > 1 &&
                 roundoff < log->l_mp->m_sb.sb_logsunit)
-		|| 
-		(log->l_mp->m_sb.sb_logsunit <= 1 && 
+		||
+		(log->l_mp->m_sb.sb_logsunit <= 1 &&
 		 roundoff < BBTOB(1)));
 
 	/* move grant heads by roundoff in sync */
@@ -1859,7 +1860,7 @@ xlog_sync(
 	xlog_grant_add_space(log, &log->l_write_head.grant, roundoff);
 
 	/* put cycle number in every block */
-	xlog_pack_data(log, iclog, roundoff); 
+	xlog_pack_data(log, iclog, roundoff);
 
 	/* real byte length */
 	size = iclog->ic_offset;
@@ -2604,7 +2605,7 @@ xlog_state_clean_log(
 			 */
 			if (!changed &&
 			   (be32_to_cpu(iclog->ic_header.h_num_logops) ==
-			   		XLOG_COVER_OPS)) {
+					XLOG_COVER_OPS)) {
 				changed = 1;
 			} else {
 				/*
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 7864a298f7eb..14bf1bdcd3bc 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -108,7 +108,7 @@ xlog_verify_bp(
  * to map to a range of nbblks basic blocks at any valid (basic
  * block) offset within the log.
  */
-STATIC xfs_buf_t *
+STATIC struct xfs_buf *
 xlog_get_bp(
 	struct xlog	*log,
 	int		nbblks)
@@ -154,7 +154,7 @@ xlog_get_bp(
 
 STATIC void
 xlog_put_bp(
-	xfs_buf_t	*bp)
+	struct xfs_buf	*bp)
 {
 	xfs_buf_free(bp);
 }
@@ -467,7 +467,7 @@ xlog_find_verify_cycle(
 {
 	xfs_daddr_t	i, j;
 	uint		cycle;
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	xfs_daddr_t	bufblks;
 	char		*buf = NULL;
 	int		error = 0;
@@ -534,7 +534,7 @@ xlog_find_verify_log_record(
 	int			extra_bblks)
 {
 	xfs_daddr_t		i;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	char			*offset = NULL;
 	xlog_rec_header_t	*head = NULL;
 	int			error = 0;
@@ -641,7 +641,7 @@ xlog_find_head(
 	struct xlog	*log,
 	xfs_daddr_t	*return_head_blk)
 {
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	char		*offset;
 	xfs_daddr_t	new_blk, first_blk, start_blk, last_blk, head_blk;
 	int		num_scan_bblks;
@@ -1380,7 +1380,7 @@ xlog_find_tail(
 {
 	xlog_rec_header_t	*rhead;
 	char			*offset = NULL;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			error;
 	xfs_daddr_t		rhead_blk;
 	xfs_lsn_t		tail_lsn;
@@ -1529,12 +1529,12 @@ xlog_find_zeroed(
 	struct xlog	*log,
 	xfs_daddr_t	*blk_no)
 {
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	char		*offset;
-	uint	        first_cycle, last_cycle;
+	uint		first_cycle, last_cycle;
 	xfs_daddr_t	new_blk, last_blk, start_blk;
-	xfs_daddr_t     num_scan_bblks;
-	int	        error, log_bbnum = log->l_logBBsize;
+	xfs_daddr_t	num_scan_bblks;
+	int		error, log_bbnum = log->l_logBBsize;
 
 	*blk_no = 0;
 
@@ -1659,7 +1659,7 @@ xlog_write_log_records(
 	int		tail_block)
 {
 	char		*offset;
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	int		balign, ealign;
 	int		sectbb = log->l_sectBBsize;
 	int		end_block = start_block + blocks;
@@ -2802,7 +2802,7 @@ xlog_recover_buffer_pass2(
 {
 	xfs_buf_log_format_t	*buf_f = item->ri_buf[0].i_addr;
 	xfs_mount_t		*mp = log->l_mp;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	int			error;
 	uint			buf_flags;
 	xfs_lsn_t		lsn;
@@ -2995,7 +2995,7 @@ xlog_recover_inode_pass2(
 {
 	struct xfs_inode_log_format	*in_f;
 	xfs_mount_t		*mp = log->l_mp;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	xfs_dinode_t		*dip;
 	int			len;
 	char			*src;
@@ -3308,7 +3308,7 @@ xlog_recover_dquot_pass2(
 	xfs_lsn_t			current_lsn)
 {
 	xfs_mount_t		*mp = log->l_mp;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	struct xfs_disk_dquot	*ddq, *recddq;
 	xfs_failaddr_t		fa;
 	int			error;
@@ -5016,7 +5016,7 @@ xlog_recover_clear_agi_bucket(
 {
 	xfs_trans_t	*tp;
 	xfs_agi_t	*agi;
-	xfs_buf_t	*agibp;
+	struct xfs_buf	*agibp;
 	int		offset;
 	int		error;
 
@@ -5123,7 +5123,7 @@ xlog_recover_process_iunlinks(
 	xfs_mount_t	*mp;
 	xfs_agnumber_t	agno;
 	xfs_agi_t	*agi;
-	xfs_buf_t	*agibp;
+	struct xfs_buf	*agibp;
 	xfs_agino_t	agino;
 	int		bucket;
 	int		error;
@@ -5322,7 +5322,7 @@ xlog_do_recovery_pass(
 	xfs_daddr_t		blk_no, rblk_no;
 	xfs_daddr_t		rhead_blk;
 	char			*offset;
-	xfs_buf_t		*hbp, *dbp;
+	struct xfs_buf		*hbp, *dbp;
 	int			error = 0, h_size, h_len;
 	int			error2 = 0;
 	int			bblks, split_bblks;
@@ -5670,7 +5670,7 @@ xlog_do_recover(
 {
 	struct xfs_mount *mp = log->l_mp;
 	int		error;
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	xfs_sb_t	*sbp;
 
 	trace_xfs_log_recover(log, head_blk, tail_blk);
@@ -5900,8 +5900,8 @@ xlog_recover_check_summary(
 {
 	xfs_mount_t	*mp;
 	xfs_agf_t	*agfp;
-	xfs_buf_t	*agfbp;
-	xfs_buf_t	*agibp;
+	struct xfs_buf	*agfbp;
+	struct xfs_buf	*agibp;
 	xfs_agnumber_t	agno;
 	uint64_t	freeblks;
 	uint64_t	itotal;
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 6b9f44df7918..ccffb6358cf5 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -835,10 +835,10 @@ xfs_qm_qino_alloc(
 
 STATIC void
 xfs_qm_reset_dqcounts(
-	xfs_mount_t	*mp,
-	xfs_buf_t	*bp,
-	xfs_dqid_t	id,
-	uint		type)
+	xfs_mount_t		*mp,
+	struct xfs_buf		*bp,
+	xfs_dqid_t		id,
+	uint			type)
 {
 	struct xfs_dqblk	*dqb;
 	int			j;
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 488719d43ca8..5357646854cf 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -50,7 +50,7 @@ xfs_rtget_summary(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	int		log,		/* log2 of extent size */
 	xfs_rtblock_t	bbno,		/* bitmap block number */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_suminfo_t	*sum)		/* out: summary info for this block */
 {
@@ -68,7 +68,7 @@ xfs_rtany_summary(
 	int		low,		/* low log2 extent size */
 	int		high,		/* high log2 extent size */
 	xfs_rtblock_t	bbno,		/* bitmap block number */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	int		*stat)		/* out: any good extents here? */
 {
@@ -114,7 +114,7 @@ xfs_rtcopy_summary(
 	xfs_trans_t	*tp)		/* transaction pointer */
 {
 	xfs_rtblock_t	bbno;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* summary buffer */
+	struct xfs_buf	*bp;		/* summary buffer */
 	int		error;		/* error return value */
 	int		log;		/* summary level number (log length) */
 	xfs_suminfo_t	sum;		/* summary data */
@@ -154,7 +154,7 @@ xfs_rtallocate_range(
 	xfs_trans_t	*tp,		/* transaction pointer */
 	xfs_rtblock_t	start,		/* start block to allocate */
 	xfs_extlen_t	len,		/* length to allocate */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
 {
 	xfs_rtblock_t	end;		/* end of the allocated extent */
@@ -236,7 +236,7 @@ xfs_rtallocate_extent_block(
 	xfs_extlen_t	maxlen,		/* maximum length to allocate */
 	xfs_extlen_t	*len,		/* out: actual length allocated */
 	xfs_rtblock_t	*nextp,		/* out: next block to try */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_extlen_t	prod,		/* extent product factor */
 	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
@@ -348,7 +348,7 @@ xfs_rtallocate_extent_exact(
 	xfs_extlen_t	minlen,		/* minimum length to allocate */
 	xfs_extlen_t	maxlen,		/* maximum length to allocate */
 	xfs_extlen_t	*len,		/* out: actual length allocated */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_extlen_t	prod,		/* extent product factor */
 	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
@@ -427,7 +427,7 @@ xfs_rtallocate_extent_near(
 	xfs_extlen_t	minlen,		/* minimum length to allocate */
 	xfs_extlen_t	maxlen,		/* maximum length to allocate */
 	xfs_extlen_t	*len,		/* out: actual length allocated */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_extlen_t	prod,		/* extent product factor */
 	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
@@ -621,7 +621,7 @@ xfs_rtallocate_extent_size(
 	xfs_extlen_t	minlen,		/* minimum length to allocate */
 	xfs_extlen_t	maxlen,		/* maximum length to allocate */
 	xfs_extlen_t	*len,		/* out: actual length allocated */
-	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
+	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
 	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
 	xfs_extlen_t	prod,		/* extent product factor */
 	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
@@ -882,7 +882,7 @@ xfs_growfs_rt(
 	xfs_growfs_rt_t	*in)		/* growfs rt input struct */
 {
 	xfs_rtblock_t	bmbno;		/* bitmap block number */
-	xfs_buf_t	*bp;		/* temporary buffer */
+	struct xfs_buf	*bp;		/* temporary buffer */
 	int		error;		/* error return value */
 	xfs_mount_t	*nmp;		/* new (fake) mount structure */
 	xfs_rfsblock_t	nrblocks;	/* new number of realtime blocks */
@@ -1101,7 +1101,7 @@ xfs_rtallocate_extent(
 	int		error;		/* error value */
 	xfs_rtblock_t	r;		/* result allocated block */
 	xfs_fsblock_t	sb;		/* summary file block number */
-	xfs_buf_t	*sumbp;		/* summary file block buffer */
+	struct xfs_buf	*sumbp;		/* summary file block buffer */
 
 	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
 	ASSERT(minlen > 0 && minlen <= maxlen);
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 3f30f846d7f2..870e14de2bcd 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -122,10 +122,10 @@ int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
 		       xfs_rtblock_t start, xfs_extlen_t len, int val);
 int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
 			     int log, xfs_rtblock_t bbno, int delta,
-			     xfs_buf_t **rbpp, xfs_fsblock_t *rsb,
+			     struct xfs_buf **rbpp, xfs_fsblock_t *rsb,
 			     xfs_suminfo_t *sum);
 int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
-			 xfs_rtblock_t bbno, int delta, xfs_buf_t **rbpp,
+			 xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp,
 			 xfs_fsblock_t *rsb);
 int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
 		     xfs_rtblock_t start, xfs_extlen_t len,
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 2e9e793a8f9d..8ce22719c820 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -186,7 +186,7 @@ xfs_symlink(
 	const char		*cur_chunk;
 	int			byte_cnt;
 	int			n;
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	prid_t			prid;
 	struct xfs_dquot	*udqp = NULL;
 	struct xfs_dquot	*gdqp = NULL;
@@ -411,17 +411,17 @@ STATIC int
 xfs_inactive_symlink_rmt(
 	struct xfs_inode *ip)
 {
-	xfs_buf_t	*bp;
-	int		done;
-	int		error;
-	xfs_fsblock_t	first_block;
+	struct xfs_buf		*bp;
+	int			done;
+	int			error;
+	xfs_fsblock_t		first_block;
 	struct xfs_defer_ops	dfops;
-	int		i;
-	xfs_mount_t	*mp;
-	xfs_bmbt_irec_t	mval[XFS_SYMLINK_MAPS];
-	int		nmaps;
-	int		size;
-	xfs_trans_t	*tp;
+	int			i;
+	xfs_mount_t		*mp;
+	xfs_bmbt_irec_t		mval[XFS_SYMLINK_MAPS];
+	int			nmaps;
+	int			size;
+	xfs_trans_t		*tp;
 
 	mp = ip->i_mount;
 	ASSERT(ip->i_df.if_flags & XFS_IFEXTENTS);
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 86f92df32c42..7d67b7274bff 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -434,7 +434,7 @@ xfs_trans_apply_sb_deltas(
 	xfs_trans_t	*tp)
 {
 	xfs_dsb_t	*sbp;
-	xfs_buf_t	*bp;
+	struct xfs_buf	*bp;
 	int		whole = 0;
 
 	bp = xfs_trans_getsb(tp, tp->t_mountp, 0);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 815b53d20e26..571fe499a48f 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -82,7 +82,7 @@ struct xfs_item_ops {
 	void (*iop_unlock)(xfs_log_item_t *);
 	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
 	void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
-	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
+	void (*iop_error)(xfs_log_item_t *, struct xfs_buf *);
 };
 
 void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 74563cd2970c..5359c4bd95e8 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -138,7 +138,7 @@ xfs_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;
 
 	if (!tp)
@@ -187,13 +187,13 @@ xfs_trans_get_buf_map(
  * buffer is a private buffer which we keep a pointer to in the
  * mount structure.
  */
-xfs_buf_t *
+struct xfs_buf *
 xfs_trans_getsb(
 	xfs_trans_t		*tp,
 	struct xfs_mount	*mp,
 	int			flags)
 {
-	xfs_buf_t		*bp;
+	struct xfs_buf		*bp;
 	struct xfs_buf_log_item	*bip;
 
 	/*
@@ -355,7 +355,7 @@ xfs_trans_read_buf_map(
 void
 xfs_trans_brelse(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip;
 	int			freed;
@@ -460,7 +460,7 @@ xfs_trans_brelse(
 void
 xfs_trans_bhold(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -481,7 +481,7 @@ xfs_trans_bhold(
 void
 xfs_trans_bhold_release(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -605,7 +605,7 @@ xfs_trans_log_buf(
 void
 xfs_trans_binval(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 	int			i;
@@ -660,7 +660,7 @@ xfs_trans_binval(
 void
 xfs_trans_inode_buf(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -684,7 +684,7 @@ xfs_trans_inode_buf(
 void
 xfs_trans_stale_inode_buf(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -709,7 +709,7 @@ xfs_trans_stale_inode_buf(
 void
 xfs_trans_inode_alloc_buf(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp)
+	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
 
@@ -802,7 +802,7 @@ xfs_trans_buf_copy_type(
 void
 xfs_trans_dquot_buf(
 	xfs_trans_t		*tp,
-	xfs_buf_t		*bp,
+	struct xfs_buf		*bp,
 	uint			type)
 {
 	struct xfs_buf_log_item	*bip = bp->b_fspriv;
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/4] Split buffer's b_fspriv field
  2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
  2018-01-19 14:08 ` [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef Carlos Maiolino
  2018-01-19 14:08 ` [PATCH 2/4] Get rid of xfs_buf_t typedef Carlos Maiolino
@ 2018-01-19 14:08 ` Carlos Maiolino
  2018-01-19 14:08 ` [PATCH 4/4] Use list_head infra-structure for buffer's log items list Carlos Maiolino
  2018-01-19 21:43 ` [PATCH 0/4] Buffer's log item refactoring Darrick J. Wong
  4 siblings, 0 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 14:08 UTC (permalink / raw)
  To: linux-xfs

By splitting the b_fspriv field into two different fields (b_log_item
and b_li_list). It's possible to get rid of an old ABI workaround, by
using the new b_log_item field to store xfs_buf_log_item separated from
the log items attached to the buffer, which will be linked in the new
b_li_list field.

This way, there is no more need to reorder the log items list to place
the buf_log_item at the beginning of the list, simplifying a bit the
logic to handle buffer IO.

This also opens the possibility to change buffer's log items list into a
proper list_head.

b_log_item field is still defined as a void *, because it is still used
by the log buffers to store xlog_in_core structures, and there is no
need to add an extra field on xfs_buf just for xlog_in_core.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          |  4 +-
 fs/xfs/libxfs/xfs_attr_leaf.c      |  2 +-
 fs/xfs/libxfs/xfs_btree.c          |  4 +-
 fs/xfs/libxfs/xfs_da_btree.c       |  2 +-
 fs/xfs/libxfs/xfs_dir2_block.c     |  2 +-
 fs/xfs/libxfs/xfs_dir2_data.c      |  2 +-
 fs/xfs/libxfs/xfs_dir2_leaf.c      |  2 +-
 fs/xfs/libxfs/xfs_dir2_node.c      |  2 +-
 fs/xfs/libxfs/xfs_ialloc.c         |  2 +-
 fs/xfs/libxfs/xfs_sb.c             |  2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c |  2 +-
 fs/xfs/xfs_buf.h                   |  3 +-
 fs/xfs/xfs_buf_item.c              | 88 +++++++++++++++++++++++---------------
 fs/xfs/xfs_inode.c                 |  4 +-
 fs/xfs/xfs_inode_item.c            |  4 +-
 fs/xfs/xfs_log.c                   |  8 ++--
 fs/xfs/xfs_log_recover.c           |  6 +--
 fs/xfs/xfs_trans_buf.c             | 48 ++++++++++-----------
 18 files changed, 104 insertions(+), 83 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index b41999fcbbe0..17dd7ff7a8f3 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -591,7 +591,7 @@ xfs_agfl_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
 	/* no verification of non-crc AGFLs */
@@ -2488,7 +2488,7 @@ xfs_agf_write_verify(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
 	fa = xfs_agf_verify(bp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 6fddce7bbd54..516ed1bec27c 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -293,7 +293,7 @@ xfs_attr3_leaf_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index cc501b7d1fc5..f3c647b2b341 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -273,7 +273,7 @@ xfs_btree_lblock_calc_crc(
 	struct xfs_buf		*bp)
 {
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	if (!xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb))
 		return;
@@ -311,7 +311,7 @@ xfs_btree_sblock_calc_crc(
 	struct xfs_buf		*bp)
 {
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	if (!xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb))
 		return;
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index cf07585b9d83..ea187b4a7991 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -182,7 +182,7 @@ xfs_da3_node_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index fe951fa1a583..2da86a394bcf 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -103,7 +103,7 @@ xfs_dir3_block_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 32378122cd1f..3ddce2f9b4dc 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -311,7 +311,7 @@ xfs_dir3_data_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index a7ad649398c7..d7e630f41f9c 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -208,7 +208,7 @@ __write_verify(
 	uint16_t	magic)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 915c4fe5e4c3..e3056c1538e4 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -141,7 +141,7 @@ xfs_dir3_free_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 1580912fe5a2..ecd8f6cb16df 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2558,7 +2558,7 @@ xfs_agi_write_verify(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
 	fa = xfs_agi_verify(bp);
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 35b005d66977..d327a188d1e6 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -674,7 +674,7 @@ xfs_sb_write_verify(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	int			error;
 
 	error = xfs_sb_verify(bp, false);
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 091e3cf0868f..5ef5f354587e 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -149,7 +149,7 @@ xfs_symlink_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
 	/* no verification of non-crc buffers */
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 90f09e89cda2..21a20d91e9e9 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -176,7 +176,8 @@ struct xfs_buf {
 	struct workqueue_struct	*b_ioend_wq;	/* I/O completion wq */
 	xfs_buf_iodone_t	b_iodone;	/* I/O completion function */
 	struct completion	b_iowait;	/* queue for I/O waiters */
-	void			*b_fspriv;
+	void			*b_log_item;
+	struct xfs_log_item	*b_li_list;
 	struct xfs_trans	*b_transp;
 	struct page		**b_pages;	/* array of page pointers */
 	struct page		*b_page_array[XB_PAGES]; /* inline pages */
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 977a2ccc32f3..cbb88a671b3a 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -411,7 +411,7 @@ xfs_buf_item_unpin(
 	int			stale = bip->bli_flags & XFS_BLI_STALE;
 	int			freed;
 
-	ASSERT(bp->b_fspriv == bip);
+	ASSERT(bp->b_log_item == bip);
 	ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
 	trace_xfs_buf_item_unpin(bip);
@@ -456,13 +456,14 @@ xfs_buf_item_unpin(
 		 */
 		if (bip->bli_flags & XFS_BLI_STALE_INODE) {
 			xfs_buf_do_callbacks(bp);
-			bp->b_fspriv = NULL;
+			bp->b_log_item = NULL;
+			bp->b_li_list = NULL;
 			bp->b_iodone = NULL;
 		} else {
 			spin_lock(&ailp->xa_lock);
 			xfs_trans_ail_delete(ailp, lip, SHUTDOWN_LOG_IO_ERROR);
 			xfs_buf_item_relse(bp);
-			ASSERT(bp->b_fspriv == NULL);
+			ASSERT(bp->b_log_item == NULL);
 		}
 		xfs_buf_relse(bp);
 	} else if (freed && remove) {
@@ -722,18 +723,15 @@ xfs_buf_item_free_format(
 
 /*
  * Allocate a new buf log item to go with the given buffer.
- * Set the buffer's b_fsprivate field to point to the new
- * buf log item.  If there are other item's attached to the
- * buffer (see xfs_buf_attach_iodone() below), then put the
- * buf log item at the front.
+ * Set the buffer's b_log_item field to point to the new
+ * buf log item.
  */
 int
 xfs_buf_item_init(
 	struct xfs_buf	*bp,
 	struct xfs_mount *mp)
 {
-	struct xfs_log_item	*lip = bp->b_fspriv;
-	struct xfs_buf_log_item	*bip;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	int			chunks;
 	int			map_size;
 	int			error;
@@ -741,13 +739,14 @@ xfs_buf_item_init(
 
 	/*
 	 * Check to see if there is already a buf log item for
-	 * this buffer.  If there is, it is guaranteed to be
-	 * the first.  If we do already have one, there is
+	 * this buffer. If we do already have one, there is
 	 * nothing to do here so return.
 	 */
 	ASSERT(bp->b_target->bt_mount == mp);
-	if (lip != NULL && lip->li_type == XFS_LI_BUF)
+	if (bip != NULL) {
+		ASSERT(bip->bli_item.li_type == XFS_LI_BUF);
 		return 0;
+	}
 
 	bip = kmem_zone_zalloc(xfs_buf_item_zone, KM_SLEEP);
 	xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops);
@@ -781,13 +780,7 @@ xfs_buf_item_init(
 		bip->bli_formats[i].blf_map_size = map_size;
 	}
 
-	/*
-	 * Put the buf item into the list of items attached to the
-	 * buffer at the front.
-	 */
-	if (bp->b_fspriv)
-		bip->bli_item.li_bio_list = bp->b_fspriv;
-	bp->b_fspriv = bip;
+	bp->b_log_item = bip;
 	xfs_buf_hold(bp);
 	return 0;
 }
@@ -961,13 +954,14 @@ void
 xfs_buf_item_relse(
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
+	struct xfs_log_item	*lip = bp->b_li_list;
 
 	trace_xfs_buf_item_relse(bp, _RET_IP_);
 	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
 
-	bp->b_fspriv = bip->bli_item.li_bio_list;
-	if (bp->b_fspriv == NULL)
+	bp->b_log_item = NULL;
+	if (lip == NULL)
 		bp->b_iodone = NULL;
 
 	xfs_buf_rele(bp);
@@ -980,9 +974,7 @@ xfs_buf_item_relse(
  * to be called when the buffer's I/O completes.  If it is not set
  * already, set the buffer's b_iodone() routine to be
  * xfs_buf_iodone_callbacks() and link the log item into the list of
- * items rooted at b_fsprivate.  Items are always added as the second
- * entry in the list if there is a first, because the buf item code
- * assumes that the buf log item is first.
+ * items rooted at b_li_list.
  */
 void
 xfs_buf_attach_iodone(
@@ -995,12 +987,12 @@ xfs_buf_attach_iodone(
 	ASSERT(xfs_buf_islocked(bp));
 
 	lip->li_cb = cb;
-	head_lip = bp->b_fspriv;
+	head_lip = bp->b_li_list;
 	if (head_lip) {
 		lip->li_bio_list = head_lip->li_bio_list;
 		head_lip->li_bio_list = lip;
 	} else {
-		bp->b_fspriv = lip;
+		bp->b_li_list = lip;
 	}
 
 	ASSERT(bp->b_iodone == NULL ||
@@ -1024,10 +1016,17 @@ STATIC void
 xfs_buf_do_callbacks(
 	struct xfs_buf		*bp)
 {
+	struct xfs_buf_log_item *blip = bp->b_log_item;
 	struct xfs_log_item	*lip;
 
-	while ((lip = bp->b_fspriv) != NULL) {
-		bp->b_fspriv = lip->li_bio_list;
+	/* If there is a buf_log_item attached, run its callback */
+	if (blip) {
+		lip = &blip->bli_item;
+		lip->li_cb(bp, lip);
+	}
+
+	while ((lip = bp->b_li_list) != NULL) {
+		bp->b_li_list = lip->li_bio_list;
 		ASSERT(lip->li_cb != NULL);
 		/*
 		 * Clear the next pointer so we don't have any
@@ -1052,9 +1051,19 @@ STATIC void
 xfs_buf_do_callbacks_fail(
 	struct xfs_buf		*bp)
 {
+	struct xfs_log_item	*lip = bp->b_li_list;
 	struct xfs_log_item	*next;
-	struct xfs_log_item	*lip = bp->b_fspriv;
-	struct xfs_ail		*ailp = lip->li_ailp;
+	struct xfs_ail		*ailp;
+
+	/*
+	 * Buffer log item errors are handled directly by xfs_buf_item_push()
+	 * and xfs_buf_iodone_callback_error, and they have no IO error
+	 * callbacks. Check only for items in b_li_list.
+	 */
+	if (lip == NULL)
+		return;
+	else
+		ailp = lip->li_ailp;
 
 	spin_lock(&ailp->xa_lock);
 	for (; lip; lip = next) {
@@ -1069,12 +1078,22 @@ static bool
 xfs_buf_iodone_callback_error(
 	struct xfs_buf		*bp)
 {
-	struct xfs_log_item	*lip = bp->b_fspriv;
-	struct xfs_mount	*mp = lip->li_mountp;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
+	struct xfs_log_item	*lip = bp->b_li_list;
+	struct xfs_mount	*mp;
 	static ulong		lasttime;
 	static xfs_buftarg_t	*lasttarg;
 	struct xfs_error_cfg	*cfg;
 
+	/*
+	 * The failed buffer might not have a buf_log_item attached or the
+	 * log_item list might be empty. Get the mp from the available xfs_log_item
+	 */
+	if (bip == NULL)
+		mp = lip->li_mountp;
+	else
+		mp = bip->bli_item.li_mountp;
+
 	/*
 	 * If we've already decided to shutdown the filesystem because of
 	 * I/O errors, there's no point in giving this a retry.
@@ -1183,7 +1202,8 @@ xfs_buf_iodone_callbacks(
 	bp->b_first_retry_time = 0;
 
 	xfs_buf_do_callbacks(bp);
-	bp->b_fspriv = NULL;
+	bp->b_log_item = NULL;
+	bp->b_li_list = NULL;
 	bp->b_iodone = NULL;
 	xfs_buf_ioend(bp);
 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 54277beb2a3d..0a4c2e48402f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2272,7 +2272,7 @@ xfs_ifree_cluster(
 		 * stale first, we will not attempt to lock them in the loop
 		 * below as the XFS_ISTALE flag will be set.
 		 */
-		lip = bp->b_fspriv;
+		lip = bp->b_li_list;
 		while (lip) {
 			if (lip->li_type == XFS_LI_INODE) {
 				iip = (xfs_inode_log_item_t *)lip;
@@ -3649,7 +3649,7 @@ xfs_iflush_int(
 	/* generate the checksum. */
 	xfs_dinode_calc_crc(mp, dip);
 
-	ASSERT(bp->b_fspriv != NULL);
+	ASSERT(bp->b_li_list != NULL);
 	ASSERT(bp->b_iodone != NULL);
 	return 0;
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 6ee5c3bf19ad..993736032b4b 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -722,7 +722,7 @@ xfs_iflush_done(
 	 * Scan the buffer IO completions for other inodes being completed and
 	 * attach them to the current inode log item.
 	 */
-	blip = bp->b_fspriv;
+	blip = bp->b_li_list;
 	prev = NULL;
 	while (blip != NULL) {
 		if (blip->li_cb != xfs_iflush_done) {
@@ -734,7 +734,7 @@ xfs_iflush_done(
 		/* remove from list */
 		next = blip->li_bio_list;
 		if (!prev) {
-			bp->b_fspriv = next;
+			bp->b_li_list = next;
 		} else {
 			prev->li_bio_list = next;
 		}
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3df424328ae3..861c84e1f674 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1243,7 +1243,7 @@ static void
 xlog_iodone(
 	struct xfs_buf		*bp)
 {
-	struct xlog_in_core	*iclog = bp->b_fspriv;
+	struct xlog_in_core	*iclog = bp->b_log_item;
 	struct xlog		*l = iclog->ic_log;
 	int			aborted = 0;
 
@@ -1774,7 +1774,7 @@ STATIC int
 xlog_bdstrat(
 	struct xfs_buf		*bp)
 {
-	struct xlog_in_core	*iclog = bp->b_fspriv;
+	struct xlog_in_core	*iclog = bp->b_log_item;
 
 	xfs_buf_lock(bp);
 	if (iclog->ic_state & XLOG_STATE_IOERROR) {
@@ -1920,7 +1920,7 @@ xlog_sync(
 	}
 
 	bp->b_io_length = BTOBB(count);
-	bp->b_fspriv = iclog;
+	bp->b_log_item = iclog;
 	bp->b_flags &= ~XBF_FLUSH;
 	bp->b_flags |= (XBF_ASYNC | XBF_SYNCIO | XBF_WRITE | XBF_FUA);
 
@@ -1959,7 +1959,7 @@ xlog_sync(
 		XFS_BUF_SET_ADDR(bp, 0);	     /* logical 0 */
 		xfs_buf_associate_memory(bp,
 				(char *)&iclog->ic_header + count, split);
-		bp->b_fspriv = iclog;
+		bp->b_log_item = iclog;
 		bp->b_flags &= ~XBF_FLUSH;
 		bp->b_flags |= (XBF_ASYNC | XBF_SYNCIO | XBF_WRITE | XBF_FUA);
 
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 14bf1bdcd3bc..846c3b152e41 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -400,9 +400,9 @@ xlog_recover_iodone(
 	 * On v5 supers, a bli could be attached to update the metadata LSN.
 	 * Clean it up.
 	 */
-	if (bp->b_fspriv)
+	if (bp->b_log_item)
 		xfs_buf_item_relse(bp);
-	ASSERT(bp->b_fspriv == NULL);
+	ASSERT(bp->b_log_item == NULL);
 
 	bp->b_iodone = NULL;
 	xfs_buf_ioend(bp);
@@ -2630,7 +2630,7 @@ xlog_recover_validate_buf_type(
 		ASSERT(!bp->b_iodone || bp->b_iodone == xlog_recover_iodone);
 		bp->b_iodone = xlog_recover_iodone;
 		xfs_buf_item_init(bp, mp);
-		bip = bp->b_fspriv;
+		bip = bp->b_log_item;
 		bip->bli_item.li_lsn = current_lsn;
 	}
 }
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 5359c4bd95e8..ffe344b6e5d2 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -82,12 +82,12 @@ _xfs_trans_bjoin(
 	ASSERT(bp->b_transp == NULL);
 
 	/*
-	 * The xfs_buf_log_item pointer is stored in b_fsprivate.  If
+	 * The xfs_buf_log_item pointer is stored in b_log_item.  If
 	 * it doesn't have one yet, then allocate one and initialize it.
 	 * The checks to see if one is there are in xfs_buf_item_init().
 	 */
 	xfs_buf_item_init(bp, tp->t_mountp);
-	bip = bp->b_fspriv;
+	bip = bp->b_log_item;
 	ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
 	ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
 	ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
@@ -118,7 +118,7 @@ xfs_trans_bjoin(
 	struct xfs_buf		*bp)
 {
 	_xfs_trans_bjoin(tp, bp, 0);
-	trace_xfs_trans_bjoin(bp->b_fspriv);
+	trace_xfs_trans_bjoin(bp->b_log_item);
 }
 
 /*
@@ -159,7 +159,7 @@ xfs_trans_get_buf_map(
 		}
 
 		ASSERT(bp->b_transp == tp);
-		bip = bp->b_fspriv;
+		bip = bp->b_log_item;
 		ASSERT(bip != NULL);
 		ASSERT(atomic_read(&bip->bli_refcount) > 0);
 		bip->bli_recur++;
@@ -175,7 +175,7 @@ xfs_trans_get_buf_map(
 	ASSERT(!bp->b_error);
 
 	_xfs_trans_bjoin(tp, bp, 1);
-	trace_xfs_trans_get_buf(bp->b_fspriv);
+	trace_xfs_trans_get_buf(bp->b_log_item);
 	return bp;
 }
 
@@ -211,7 +211,7 @@ xfs_trans_getsb(
 	 */
 	bp = mp->m_sb_bp;
 	if (bp->b_transp == tp) {
-		bip = bp->b_fspriv;
+		bip = bp->b_log_item;
 		ASSERT(bip != NULL);
 		ASSERT(atomic_read(&bip->bli_refcount) > 0);
 		bip->bli_recur++;
@@ -224,7 +224,7 @@ xfs_trans_getsb(
 		return NULL;
 
 	_xfs_trans_bjoin(tp, bp, 1);
-	trace_xfs_trans_getsb(bp->b_fspriv);
+	trace_xfs_trans_getsb(bp->b_log_item);
 	return bp;
 }
 
@@ -267,7 +267,7 @@ xfs_trans_read_buf_map(
 	if (bp) {
 		ASSERT(xfs_buf_islocked(bp));
 		ASSERT(bp->b_transp == tp);
-		ASSERT(bp->b_fspriv != NULL);
+		ASSERT(bp->b_log_item != NULL);
 		ASSERT(!bp->b_error);
 		ASSERT(bp->b_flags & XBF_DONE);
 
@@ -280,7 +280,7 @@ xfs_trans_read_buf_map(
 			return -EIO;
 		}
 
-		bip = bp->b_fspriv;
+		bip = bp->b_log_item;
 		bip->bli_recur++;
 
 		ASSERT(atomic_read(&bip->bli_refcount) > 0);
@@ -330,7 +330,7 @@ xfs_trans_read_buf_map(
 
 	if (tp) {
 		_xfs_trans_bjoin(tp, bp, 1);
-		trace_xfs_trans_read_buf(bp->b_fspriv);
+		trace_xfs_trans_read_buf(bp->b_log_item);
 	}
 	*bpp = bp;
 	return 0;
@@ -370,7 +370,7 @@ xfs_trans_brelse(
 	}
 
 	ASSERT(bp->b_transp == tp);
-	bip = bp->b_fspriv;
+	bip = bp->b_log_item;
 	ASSERT(bip->bli_item.li_type == XFS_LI_BUF);
 	ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
 	ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
@@ -462,7 +462,7 @@ xfs_trans_bhold(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -483,7 +483,7 @@ xfs_trans_bhold_release(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -504,7 +504,7 @@ xfs_trans_dirty_buf(
 	struct xfs_trans	*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -561,7 +561,7 @@ xfs_trans_log_buf(
 	uint			first,
 	uint			last)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(first <= last && last < BBTOB(bp->b_length));
 	ASSERT(!(bip->bli_flags & XFS_BLI_ORDERED));
@@ -607,7 +607,7 @@ xfs_trans_binval(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	int			i;
 
 	ASSERT(bp->b_transp == tp);
@@ -662,7 +662,7 @@ xfs_trans_inode_buf(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -686,7 +686,7 @@ xfs_trans_stale_inode_buf(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -711,7 +711,7 @@ xfs_trans_inode_alloc_buf(
 	xfs_trans_t		*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -733,7 +733,7 @@ xfs_trans_ordered_buf(
 	struct xfs_trans	*tp,
 	struct xfs_buf		*bp)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(bp->b_transp == tp);
 	ASSERT(bip != NULL);
@@ -763,7 +763,7 @@ xfs_trans_buf_set_type(
 	struct xfs_buf		*bp,
 	enum xfs_blft		type)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	if (!tp)
 		return;
@@ -780,8 +780,8 @@ xfs_trans_buf_copy_type(
 	struct xfs_buf		*dst_bp,
 	struct xfs_buf		*src_bp)
 {
-	struct xfs_buf_log_item	*sbip = src_bp->b_fspriv;
-	struct xfs_buf_log_item	*dbip = dst_bp->b_fspriv;
+	struct xfs_buf_log_item	*sbip = src_bp->b_log_item;
+	struct xfs_buf_log_item	*dbip = dst_bp->b_log_item;
 	enum xfs_blft		type;
 
 	type = xfs_blft_from_flags(&sbip->__bli_format);
@@ -805,7 +805,7 @@ xfs_trans_dquot_buf(
 	struct xfs_buf		*bp,
 	uint			type)
 {
-	struct xfs_buf_log_item	*bip = bp->b_fspriv;
+	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	ASSERT(type == XFS_BLF_UDQUOT_BUF ||
 	       type == XFS_BLF_PDQUOT_BUF ||
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
                   ` (2 preceding siblings ...)
  2018-01-19 14:08 ` [PATCH 3/4] Split buffer's b_fspriv field Carlos Maiolino
@ 2018-01-19 14:08 ` Carlos Maiolino
  2018-01-19 18:21   ` Darrick J. Wong
  2018-01-23 10:19   ` Nikolay Borisov
  2018-01-19 21:43 ` [PATCH 0/4] Buffer's log item refactoring Darrick J. Wong
  4 siblings, 2 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 14:08 UTC (permalink / raw)
  To: linux-xfs

Now that buffer's b_fspriv has been split, just replace the current
singly linked list of xfs_log_items, by the list_head infrastructure.

Also, remove the xfs_log_item argument from xfs_buf_resubmit_failed_buffers(),
there is no need for this argument, once the log items can be walked
through the list_head in the buffer.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/xfs_buf.c        |  1 +
 fs/xfs/xfs_buf.h        |  2 +-
 fs/xfs/xfs_buf_item.c   | 60 +++++++++++++++++++++----------------------------
 fs/xfs/xfs_buf_item.h   |  1 -
 fs/xfs/xfs_dquot_item.c |  2 +-
 fs/xfs/xfs_inode.c      |  8 +++----
 fs/xfs/xfs_inode_item.c | 41 ++++++++++-----------------------
 fs/xfs/xfs_log.c        |  1 +
 fs/xfs/xfs_trans.h      |  2 +-
 9 files changed, 46 insertions(+), 72 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 07dccb05e782..47e530662db9 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -236,6 +236,7 @@ _xfs_buf_alloc(
 	init_completion(&bp->b_iowait);
 	INIT_LIST_HEAD(&bp->b_lru);
 	INIT_LIST_HEAD(&bp->b_list);
+	INIT_LIST_HEAD(&bp->b_li_list);
 	sema_init(&bp->b_sema, 0); /* held, no waiters */
 	spin_lock_init(&bp->b_lock);
 	XB_SET_OWNER(bp);
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 21a20d91e9e9..503221f778d3 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -177,7 +177,7 @@ struct xfs_buf {
 	xfs_buf_iodone_t	b_iodone;	/* I/O completion function */
 	struct completion	b_iowait;	/* queue for I/O waiters */
 	void			*b_log_item;
-	struct xfs_log_item	*b_li_list;
+	struct list_head	b_li_list;	/* Log items list head */
 	struct xfs_trans	*b_transp;
 	struct page		**b_pages;	/* array of page pointers */
 	struct page		*b_page_array[XB_PAGES]; /* inline pages */
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index cbb88a671b3a..33f878b51925 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -457,7 +457,7 @@ xfs_buf_item_unpin(
 		if (bip->bli_flags & XFS_BLI_STALE_INODE) {
 			xfs_buf_do_callbacks(bp);
 			bp->b_log_item = NULL;
-			bp->b_li_list = NULL;
+			list_del_init(&bp->b_li_list);
 			bp->b_iodone = NULL;
 		} else {
 			spin_lock(&ailp->xa_lock);
@@ -955,13 +955,12 @@ xfs_buf_item_relse(
 	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	struct xfs_log_item	*lip = bp->b_li_list;
 
 	trace_xfs_buf_item_relse(bp, _RET_IP_);
 	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
 
 	bp->b_log_item = NULL;
-	if (lip == NULL)
+	if (list_empty(&bp->b_li_list))
 		bp->b_iodone = NULL;
 
 	xfs_buf_rele(bp);
@@ -982,18 +981,10 @@ xfs_buf_attach_iodone(
 	void		(*cb)(struct xfs_buf *, xfs_log_item_t *),
 	xfs_log_item_t	*lip)
 {
-	xfs_log_item_t	*head_lip;
-
 	ASSERT(xfs_buf_islocked(bp));
 
 	lip->li_cb = cb;
-	head_lip = bp->b_li_list;
-	if (head_lip) {
-		lip->li_bio_list = head_lip->li_bio_list;
-		head_lip->li_bio_list = lip;
-	} else {
-		bp->b_li_list = lip;
-	}
+	list_add_tail(&lip->li_bio_list, &bp->b_li_list);
 
 	ASSERT(bp->b_iodone == NULL ||
 	       bp->b_iodone == xfs_buf_iodone_callbacks);
@@ -1003,12 +994,12 @@ xfs_buf_attach_iodone(
 /*
  * We can have many callbacks on a buffer. Running the callbacks individually
  * can cause a lot of contention on the AIL lock, so we allow for a single
- * callback to be able to scan the remaining lip->li_bio_list for other items
+ * callback to be able to scan the remaining items in bp->b_li_list for other items
  * of the same type and callback to be processed in the first call.
  *
  * As a result, the loop walking the callback list below will also modify the
  * list. it removes the first item from the list and then runs the callback.
- * The loop then restarts from the new head of the list. This allows the
+ * The loop then restarts from the new first item int the list. This allows the
  * callback to scan and modify the list attached to the buffer and we don't
  * have to care about maintaining a next item pointer.
  */
@@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
 		lip->li_cb(bp, lip);
 	}
 
-	while ((lip = bp->b_li_list) != NULL) {
-		bp->b_li_list = lip->li_bio_list;
-		ASSERT(lip->li_cb != NULL);
+	while(!list_empty(&bp->b_li_list))
+	{
+		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
+				       li_bio_list);
+
 		/*
-		 * Clear the next pointer so we don't have any
+		 * Remove the item from the list, so we don't have any
 		 * confusion if the item is added to another buf.
 		 * Don't touch the log item after calling its
 		 * callback, because it could have freed itself.
 		 */
-		lip->li_bio_list = NULL;
-		lip->li_cb(bp, lip);
+		list_del_init(&lip->li_bio_list);
+		lip->li_cb(bp,lip);
 	}
 }
 
@@ -1051,8 +1044,7 @@ STATIC void
 xfs_buf_do_callbacks_fail(
 	struct xfs_buf		*bp)
 {
-	struct xfs_log_item	*lip = bp->b_li_list;
-	struct xfs_log_item	*next;
+	struct xfs_log_item	*lip;
 	struct xfs_ail		*ailp;
 
 	/*
@@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
 	 * and xfs_buf_iodone_callback_error, and they have no IO error
 	 * callbacks. Check only for items in b_li_list.
 	 */
-	if (lip == NULL)
+	if (list_empty(&bp->b_li_list)) {
 		return;
-	else
+	} else {
+		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
+				       li_bio_list);
 		ailp = lip->li_ailp;
+	}
 
 	spin_lock(&ailp->xa_lock);
-	for (; lip; lip = next) {
-		next = lip->li_bio_list;
+	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
 		if (lip->li_ops->iop_error)
 			lip->li_ops->iop_error(lip, bp);
 	}
@@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
 	struct xfs_buf		*bp)
 {
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	struct xfs_log_item	*lip = bp->b_li_list;
+	struct xfs_log_item	*lip;
 	struct xfs_mount	*mp;
 	static ulong		lasttime;
 	static xfs_buftarg_t	*lasttarg;
@@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
 	 * The failed buffer might not have a buf_log_item attached or the
 	 * log_item list might be empty. Get the mp from the available xfs_log_item
 	 */
-	if (bip == NULL)
+	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
+					   li_bio_list)))
 		mp = lip->li_mountp;
 	else
 		mp = bip->bli_item.li_mountp;
@@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
 
 	xfs_buf_do_callbacks(bp);
 	bp->b_log_item = NULL;
-	bp->b_li_list = NULL;
+	list_del_init(&bp->b_li_list);
 	bp->b_iodone = NULL;
 	xfs_buf_ioend(bp);
 }
@@ -1248,10 +1243,9 @@ xfs_buf_iodone(
 bool
 xfs_buf_resubmit_failed_buffers(
 	struct xfs_buf		*bp,
-	struct xfs_log_item	*lip,
 	struct list_head	*buffer_list)
 {
-	struct xfs_log_item	*next;
+	struct xfs_log_item	*lip;
 
 	/*
 	 * Clear XFS_LI_FAILED flag from all items before resubmit
@@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
 	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
 	 * function already have it acquired
 	 */
-	for (; lip; lip = next) {
-		next = lip->li_bio_list;
+	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
 		xfs_clear_li_failed(lip);
-	}
 
 	/* Add this buffer back to the delayed write list */
 	return xfs_buf_delwri_queue(bp, buffer_list);
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 0febfbbf6ba9..643f53dcfe51 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
 void	xfs_buf_iodone_callbacks(struct xfs_buf *);
 void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
 bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
-					struct xfs_log_item *,
 					struct list_head *);
 
 extern kmem_zone_t	*xfs_buf_item_zone;
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 664dea105e76..4a4539a4fad5 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
 		if (!xfs_buf_trylock(bp))
 			return XFS_ITEM_LOCKED;
 
-		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
+		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
 			rval = XFS_ITEM_FLUSHING;
 
 		xfs_buf_unlock(bp);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 0a4c2e48402f..8e26d3121be6 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
 	struct xfs_buf		*bp;
 	xfs_inode_t		*ip;
 	xfs_inode_log_item_t	*iip;
-	xfs_log_item_t		*lip;
+	struct xfs_log_item	*lip;
 	struct xfs_perag	*pag;
 	xfs_ino_t		inum;
 
@@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
 		 * stale first, we will not attempt to lock them in the loop
 		 * below as the XFS_ISTALE flag will be set.
 		 */
-		lip = bp->b_li_list;
-		while (lip) {
+		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
 			if (lip->li_type == XFS_LI_INODE) {
 				iip = (xfs_inode_log_item_t *)lip;
 				ASSERT(iip->ili_logged == 1);
@@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
 							&iip->ili_item.li_lsn);
 				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
 			}
-			lip = lip->li_bio_list;
 		}
 
 
@@ -3649,7 +3647,7 @@ xfs_iflush_int(
 	/* generate the checksum. */
 	xfs_dinode_calc_crc(mp, dip);
 
-	ASSERT(bp->b_li_list != NULL);
+	ASSERT(!list_empty(&bp->b_li_list));
 	ASSERT(bp->b_iodone != NULL);
 	return 0;
 
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 993736032b4b..ddfc2c80af5e 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -521,7 +521,7 @@ xfs_inode_item_push(
 		if (!xfs_buf_trylock(bp))
 			return XFS_ITEM_LOCKED;
 
-		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
+		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
 			rval = XFS_ITEM_FLUSHING;
 
 		xfs_buf_unlock(bp);
@@ -712,37 +712,23 @@ xfs_iflush_done(
 	struct xfs_log_item	*lip)
 {
 	struct xfs_inode_log_item *iip;
-	struct xfs_log_item	*blip;
-	struct xfs_log_item	*next;
-	struct xfs_log_item	*prev;
+	struct xfs_log_item	*blip, *n;
 	struct xfs_ail		*ailp = lip->li_ailp;
 	int			need_ail = 0;
+	LIST_HEAD(tmp);
 
 	/*
 	 * Scan the buffer IO completions for other inodes being completed and
 	 * attach them to the current inode log item.
 	 */
-	blip = bp->b_li_list;
-	prev = NULL;
-	while (blip != NULL) {
-		if (blip->li_cb != xfs_iflush_done) {
-			prev = blip;
-			blip = blip->li_bio_list;
-			continue;
-		}
 
-		/* remove from list */
-		next = blip->li_bio_list;
-		if (!prev) {
-			bp->b_li_list = next;
-		} else {
-			prev->li_bio_list = next;
-		}
+	list_add_tail(&lip->li_bio_list, &tmp);
 
-		/* add to current list */
-		blip->li_bio_list = lip->li_bio_list;
-		lip->li_bio_list = blip;
+	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
+		if (lip->li_cb != xfs_iflush_done)
+			continue;
 
+		list_move_tail(&blip->li_bio_list, &tmp);
 		/*
 		 * while we have the item, do the unlocked check for needing
 		 * the AIL lock.
@@ -751,8 +737,6 @@ xfs_iflush_done(
 		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
 		    (blip->li_flags & XFS_LI_FAILED))
 			need_ail++;
-
-		blip = next;
 	}
 
 	/* make sure we capture the state of the initial inode. */
@@ -775,7 +759,7 @@ xfs_iflush_done(
 
 		/* this is an opencoded batch version of xfs_trans_ail_delete */
 		spin_lock(&ailp->xa_lock);
-		for (blip = lip; blip; blip = blip->li_bio_list) {
+		list_for_each_entry(blip, &tmp, li_bio_list) {
 			if (INODE_ITEM(blip)->ili_logged &&
 			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
 				mlip_changed |= xfs_ail_delete_one(ailp, blip);
@@ -801,15 +785,14 @@ xfs_iflush_done(
 	 * ili_last_fields bits now that we know that the data corresponding to
 	 * them is safely on disk.
 	 */
-	for (blip = lip; blip; blip = next) {
-		next = blip->li_bio_list;
-		blip->li_bio_list = NULL;
-
+	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
+		list_del_init(&blip->li_bio_list);
 		iip = INODE_ITEM(blip);
 		iip->ili_logged = 0;
 		iip->ili_last_fields = 0;
 		xfs_ifunlock(iip->ili_inode);
 	}
+	list_del(&tmp);
 }
 
 /*
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 861c84e1f674..1b5082aeb538 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1047,6 +1047,7 @@ xfs_log_item_init(
 
 	INIT_LIST_HEAD(&item->li_ail);
 	INIT_LIST_HEAD(&item->li_cil);
+	INIT_LIST_HEAD(&item->li_bio_list);
 }
 
 /*
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 571fe499a48f..950cb9b4e36e 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -50,7 +50,7 @@ typedef struct xfs_log_item {
 	uint				li_type;	/* item type */
 	uint				li_flags;	/* misc flags */
 	struct xfs_buf			*li_buf;	/* real buffer pointer */
-	struct xfs_log_item		*li_bio_list;	/* buffer item list */
+	struct list_head		li_bio_list;	/* buffer item list */
 	void				(*li_cb)(struct xfs_buf *,
 						 struct xfs_log_item *);
 							/* buffer item iodone */
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-19 14:08 ` [PATCH 4/4] Use list_head infra-structure for buffer's log items list Carlos Maiolino
@ 2018-01-19 18:21   ` Darrick J. Wong
  2018-01-19 18:50     ` Carlos Maiolino
  2018-01-23 10:19   ` Nikolay Borisov
  1 sibling, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-19 18:21 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

On Fri, Jan 19, 2018 at 03:08:47PM +0100, Carlos Maiolino wrote:
> Now that buffer's b_fspriv has been split, just replace the current
> singly linked list of xfs_log_items, by the list_head infrastructure.
> 
> Also, remove the xfs_log_item argument from xfs_buf_resubmit_failed_buffers(),
> there is no need for this argument, once the log items can be walked
> through the list_head in the buffer.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>  fs/xfs/xfs_buf.c        |  1 +
>  fs/xfs/xfs_buf.h        |  2 +-
>  fs/xfs/xfs_buf_item.c   | 60 +++++++++++++++++++++----------------------------
>  fs/xfs/xfs_buf_item.h   |  1 -
>  fs/xfs/xfs_dquot_item.c |  2 +-
>  fs/xfs/xfs_inode.c      |  8 +++----
>  fs/xfs/xfs_inode_item.c | 41 ++++++++++-----------------------
>  fs/xfs/xfs_log.c        |  1 +
>  fs/xfs/xfs_trans.h      |  2 +-
>  9 files changed, 46 insertions(+), 72 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 07dccb05e782..47e530662db9 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -236,6 +236,7 @@ _xfs_buf_alloc(
>  	init_completion(&bp->b_iowait);
>  	INIT_LIST_HEAD(&bp->b_lru);
>  	INIT_LIST_HEAD(&bp->b_list);
> +	INIT_LIST_HEAD(&bp->b_li_list);
>  	sema_init(&bp->b_sema, 0); /* held, no waiters */
>  	spin_lock_init(&bp->b_lock);
>  	XB_SET_OWNER(bp);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 21a20d91e9e9..503221f778d3 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -177,7 +177,7 @@ struct xfs_buf {
>  	xfs_buf_iodone_t	b_iodone;	/* I/O completion function */
>  	struct completion	b_iowait;	/* queue for I/O waiters */
>  	void			*b_log_item;
> -	struct xfs_log_item	*b_li_list;
> +	struct list_head	b_li_list;	/* Log items list head */
>  	struct xfs_trans	*b_transp;
>  	struct page		**b_pages;	/* array of page pointers */
>  	struct page		*b_page_array[XB_PAGES]; /* inline pages */
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index cbb88a671b3a..33f878b51925 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -457,7 +457,7 @@ xfs_buf_item_unpin(
>  		if (bip->bli_flags & XFS_BLI_STALE_INODE) {
>  			xfs_buf_do_callbacks(bp);
>  			bp->b_log_item = NULL;
> -			bp->b_li_list = NULL;
> +			list_del_init(&bp->b_li_list);
>  			bp->b_iodone = NULL;
>  		} else {
>  			spin_lock(&ailp->xa_lock);
> @@ -955,13 +955,12 @@ xfs_buf_item_relse(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> -	struct xfs_log_item	*lip = bp->b_li_list;
>  
>  	trace_xfs_buf_item_relse(bp, _RET_IP_);
>  	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
>  
>  	bp->b_log_item = NULL;
> -	if (lip == NULL)
> +	if (list_empty(&bp->b_li_list))
>  		bp->b_iodone = NULL;
>  
>  	xfs_buf_rele(bp);
> @@ -982,18 +981,10 @@ xfs_buf_attach_iodone(
>  	void		(*cb)(struct xfs_buf *, xfs_log_item_t *),
>  	xfs_log_item_t	*lip)
>  {
> -	xfs_log_item_t	*head_lip;
> -
>  	ASSERT(xfs_buf_islocked(bp));
>  
>  	lip->li_cb = cb;
> -	head_lip = bp->b_li_list;
> -	if (head_lip) {
> -		lip->li_bio_list = head_lip->li_bio_list;
> -		head_lip->li_bio_list = lip;
> -	} else {
> -		bp->b_li_list = lip;
> -	}
> +	list_add_tail(&lip->li_bio_list, &bp->b_li_list);
>  
>  	ASSERT(bp->b_iodone == NULL ||
>  	       bp->b_iodone == xfs_buf_iodone_callbacks);
> @@ -1003,12 +994,12 @@ xfs_buf_attach_iodone(
>  /*
>   * We can have many callbacks on a buffer. Running the callbacks individually
>   * can cause a lot of contention on the AIL lock, so we allow for a single
> - * callback to be able to scan the remaining lip->li_bio_list for other items
> + * callback to be able to scan the remaining items in bp->b_li_list for other items
>   * of the same type and callback to be processed in the first call.
>   *
>   * As a result, the loop walking the callback list below will also modify the
>   * list. it removes the first item from the list and then runs the callback.
> - * The loop then restarts from the new head of the list. This allows the
> + * The loop then restarts from the new first item int the list. This allows the
>   * callback to scan and modify the list attached to the buffer and we don't
>   * have to care about maintaining a next item pointer.
>   */
> @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
>  		lip->li_cb(bp, lip);
>  	}
>  
> -	while ((lip = bp->b_li_list) != NULL) {
> -		bp->b_li_list = lip->li_bio_list;
> -		ASSERT(lip->li_cb != NULL);
> +	while(!list_empty(&bp->b_li_list))

while (!list_empty(...))

> +	{
> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> +				       li_bio_list);
> +
>  		/*
> -		 * Clear the next pointer so we don't have any
> +		 * Remove the item from the list, so we don't have any
>  		 * confusion if the item is added to another buf.
>  		 * Don't touch the log item after calling its
>  		 * callback, because it could have freed itself.
>  		 */
> -		lip->li_bio_list = NULL;
> -		lip->li_cb(bp, lip);
> +		list_del_init(&lip->li_bio_list);
> +		lip->li_cb(bp,lip);
>  	}
>  }
>  
> @@ -1051,8 +1044,7 @@ STATIC void
>  xfs_buf_do_callbacks_fail(
>  	struct xfs_buf		*bp)
>  {
> -	struct xfs_log_item	*lip = bp->b_li_list;
> -	struct xfs_log_item	*next;
> +	struct xfs_log_item	*lip;
>  	struct xfs_ail		*ailp;
>  
>  	/*
> @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
>  	 * and xfs_buf_iodone_callback_error, and they have no IO error
>  	 * callbacks. Check only for items in b_li_list.
>  	 */
> -	if (lip == NULL)
> +	if (list_empty(&bp->b_li_list)) {
>  		return;
> -	else
> +	} else {
> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> +				       li_bio_list);
>  		ailp = lip->li_ailp;
> +	}

How about:

if (list_empty(&bp->b_li_list))
	return;

lip = list_first_entry(...);
ailp = lip->li_ailp;

spin_lock(&ailp->xa_lock);

>  
>  	spin_lock(&ailp->xa_lock);
> -	for (; lip; lip = next) {
> -		next = lip->li_bio_list;
> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>  		if (lip->li_ops->iop_error)
>  			lip->li_ops->iop_error(lip, bp);
>  	}
> @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> -	struct xfs_log_item	*lip = bp->b_li_list;
> +	struct xfs_log_item	*lip;
>  	struct xfs_mount	*mp;
>  	static ulong		lasttime;
>  	static xfs_buftarg_t	*lasttarg;
> @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
>  	 * The failed buffer might not have a buf_log_item attached or the
>  	 * log_item list might be empty. Get the mp from the available xfs_log_item
>  	 */
> -	if (bip == NULL)
> +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> +					   li_bio_list)))

lip = list_first_entry_or_null(...);
mp = lip ? lip->li_mountp : bip->bli_item.li_mountp;

Looks mostly ok, though with some minor style issues.

--D

>  		mp = lip->li_mountp;
>  	else
>  		mp = bip->bli_item.li_mountp;
> @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
>  
>  	xfs_buf_do_callbacks(bp);
>  	bp->b_log_item = NULL;
> -	bp->b_li_list = NULL;
> +	list_del_init(&bp->b_li_list);
>  	bp->b_iodone = NULL;
>  	xfs_buf_ioend(bp);
>  }
> @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
>  bool
>  xfs_buf_resubmit_failed_buffers(
>  	struct xfs_buf		*bp,
> -	struct xfs_log_item	*lip,
>  	struct list_head	*buffer_list)
>  {
> -	struct xfs_log_item	*next;
> +	struct xfs_log_item	*lip;
>  
>  	/*
>  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
>  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
>  	 * function already have it acquired
>  	 */
> -	for (; lip; lip = next) {
> -		next = lip->li_bio_list;
> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
>  		xfs_clear_li_failed(lip);
> -	}
>  
>  	/* Add this buffer back to the delayed write list */
>  	return xfs_buf_delwri_queue(bp, buffer_list);
> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> index 0febfbbf6ba9..643f53dcfe51 100644
> --- a/fs/xfs/xfs_buf_item.h
> +++ b/fs/xfs/xfs_buf_item.h
> @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> -					struct xfs_log_item *,
>  					struct list_head *);
>  
>  extern kmem_zone_t	*xfs_buf_item_zone;
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index 664dea105e76..4a4539a4fad5 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
>  		if (!xfs_buf_trylock(bp))
>  			return XFS_ITEM_LOCKED;
>  
> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>  			rval = XFS_ITEM_FLUSHING;
>  
>  		xfs_buf_unlock(bp);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 0a4c2e48402f..8e26d3121be6 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
>  	struct xfs_buf		*bp;
>  	xfs_inode_t		*ip;
>  	xfs_inode_log_item_t	*iip;
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  	struct xfs_perag	*pag;
>  	xfs_ino_t		inum;
>  
> @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
>  		 * stale first, we will not attempt to lock them in the loop
>  		 * below as the XFS_ISTALE flag will be set.
>  		 */
> -		lip = bp->b_li_list;
> -		while (lip) {
> +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>  			if (lip->li_type == XFS_LI_INODE) {
>  				iip = (xfs_inode_log_item_t *)lip;
>  				ASSERT(iip->ili_logged == 1);
> @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
>  							&iip->ili_item.li_lsn);
>  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
>  			}
> -			lip = lip->li_bio_list;
>  		}
>  
>  
> @@ -3649,7 +3647,7 @@ xfs_iflush_int(
>  	/* generate the checksum. */
>  	xfs_dinode_calc_crc(mp, dip);
>  
> -	ASSERT(bp->b_li_list != NULL);
> +	ASSERT(!list_empty(&bp->b_li_list));
>  	ASSERT(bp->b_iodone != NULL);
>  	return 0;
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 993736032b4b..ddfc2c80af5e 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -521,7 +521,7 @@ xfs_inode_item_push(
>  		if (!xfs_buf_trylock(bp))
>  			return XFS_ITEM_LOCKED;
>  
> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>  			rval = XFS_ITEM_FLUSHING;
>  
>  		xfs_buf_unlock(bp);
> @@ -712,37 +712,23 @@ xfs_iflush_done(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_inode_log_item *iip;
> -	struct xfs_log_item	*blip;
> -	struct xfs_log_item	*next;
> -	struct xfs_log_item	*prev;
> +	struct xfs_log_item	*blip, *n;
>  	struct xfs_ail		*ailp = lip->li_ailp;
>  	int			need_ail = 0;
> +	LIST_HEAD(tmp);
>  
>  	/*
>  	 * Scan the buffer IO completions for other inodes being completed and
>  	 * attach them to the current inode log item.
>  	 */
> -	blip = bp->b_li_list;
> -	prev = NULL;
> -	while (blip != NULL) {
> -		if (blip->li_cb != xfs_iflush_done) {
> -			prev = blip;
> -			blip = blip->li_bio_list;
> -			continue;
> -		}
>  
> -		/* remove from list */
> -		next = blip->li_bio_list;
> -		if (!prev) {
> -			bp->b_li_list = next;
> -		} else {
> -			prev->li_bio_list = next;
> -		}
> +	list_add_tail(&lip->li_bio_list, &tmp);
>  
> -		/* add to current list */
> -		blip->li_bio_list = lip->li_bio_list;
> -		lip->li_bio_list = blip;
> +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> +		if (lip->li_cb != xfs_iflush_done)
> +			continue;
>  
> +		list_move_tail(&blip->li_bio_list, &tmp);
>  		/*
>  		 * while we have the item, do the unlocked check for needing
>  		 * the AIL lock.
> @@ -751,8 +737,6 @@ xfs_iflush_done(
>  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
>  		    (blip->li_flags & XFS_LI_FAILED))
>  			need_ail++;
> -
> -		blip = next;
>  	}
>  
>  	/* make sure we capture the state of the initial inode. */
> @@ -775,7 +759,7 @@ xfs_iflush_done(
>  
>  		/* this is an opencoded batch version of xfs_trans_ail_delete */
>  		spin_lock(&ailp->xa_lock);
> -		for (blip = lip; blip; blip = blip->li_bio_list) {
> +		list_for_each_entry(blip, &tmp, li_bio_list) {
>  			if (INODE_ITEM(blip)->ili_logged &&
>  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
>  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> @@ -801,15 +785,14 @@ xfs_iflush_done(
>  	 * ili_last_fields bits now that we know that the data corresponding to
>  	 * them is safely on disk.
>  	 */
> -	for (blip = lip; blip; blip = next) {
> -		next = blip->li_bio_list;
> -		blip->li_bio_list = NULL;
> -
> +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> +		list_del_init(&blip->li_bio_list);
>  		iip = INODE_ITEM(blip);
>  		iip->ili_logged = 0;
>  		iip->ili_last_fields = 0;
>  		xfs_ifunlock(iip->ili_inode);
>  	}
> +	list_del(&tmp);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 861c84e1f674..1b5082aeb538 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1047,6 +1047,7 @@ xfs_log_item_init(
>  
>  	INIT_LIST_HEAD(&item->li_ail);
>  	INIT_LIST_HEAD(&item->li_cil);
> +	INIT_LIST_HEAD(&item->li_bio_list);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 571fe499a48f..950cb9b4e36e 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
>  	uint				li_type;	/* item type */
>  	uint				li_flags;	/* misc flags */
>  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> +	struct list_head		li_bio_list;	/* buffer item list */
>  	void				(*li_cb)(struct xfs_buf *,
>  						 struct xfs_log_item *);
>  							/* buffer item iodone */
> -- 
> 2.14.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-19 18:21   ` Darrick J. Wong
@ 2018-01-19 18:50     ` Carlos Maiolino
  0 siblings, 0 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-19 18:50 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

> > -	while ((lip = bp->b_li_list) != NULL) {
> > -		bp->b_li_list = lip->li_bio_list;
> > -		ASSERT(lip->li_cb != NULL);
> > +	while(!list_empty(&bp->b_li_list))
> 
> while (!list_empty(...))

Whoops, fixing....
> 
> > +	{
> > +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > +				       li_bio_list);
> > +
> >  		/*
> > -		 * Clear the next pointer so we don't have any
> > +		 * Remove the item from the list, so we don't have any
> >  		 * confusion if the item is added to another buf.
> >  		 * Don't touch the log item after calling its
> >  		 * callback, because it could have freed itself.
> >  		 */
> > -		lip->li_bio_list = NULL;
> > -		lip->li_cb(bp, lip);
> > +		list_del_init(&lip->li_bio_list);
> > +		lip->li_cb(bp,lip);
> >  	}
> >  }
> >  
> > @@ -1051,8 +1044,7 @@ STATIC void
> >  xfs_buf_do_callbacks_fail(
> >  	struct xfs_buf		*bp)
> >  {
> > -	struct xfs_log_item	*lip = bp->b_li_list;
> > -	struct xfs_log_item	*next;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_ail		*ailp;
> >  
> >  	/*
> > @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
> >  	 * and xfs_buf_iodone_callback_error, and they have no IO error
> >  	 * callbacks. Check only for items in b_li_list.
> >  	 */
> > -	if (lip == NULL)
> > +	if (list_empty(&bp->b_li_list)) {
> >  		return;
> > -	else
> > +	} else {
> > +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > +				       li_bio_list);
> >  		ailp = lip->li_ailp;
> > +	}
> 
> How about:
> 
> if (list_empty(&bp->b_li_list))
> 	return;
> 
> lip = list_first_entry(...);
> ailp = lip->li_ailp;
> 
> spin_lock(&ailp->xa_lock);

I don't think asm code will be different, but I agree this looks better, will
change


> 
> >  
> >  	spin_lock(&ailp->xa_lock);
> > -	for (; lip; lip = next) {
> > -		next = lip->li_bio_list;
> > +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >  		if (lip->li_ops->iop_error)
> >  			lip->li_ops->iop_error(lip, bp);
> >  	}
> > @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
> >  	struct xfs_buf		*bp)
> >  {
> >  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> > -	struct xfs_log_item	*lip = bp->b_li_list;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_mount	*mp;
> >  	static ulong		lasttime;
> >  	static xfs_buftarg_t	*lasttarg;
> > @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
> >  	 * The failed buffer might not have a buf_log_item attached or the
> >  	 * log_item list might be empty. Get the mp from the available xfs_log_item
> >  	 */
> > -	if (bip == NULL)
> > +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> > +					   li_bio_list)))
> 
> lip = list_first_entry_or_null(...);
> mp = lip ? lip->li_mountp : bip->bli_item.li_mountp;
> 

ok

> Looks mostly ok, though with some minor style issues.
> 

Thanks for the review, I forgot to check the patches with checkpatch.pl, I'll do
that.

Cheers.

> --D
> 
> >  		mp = lip->li_mountp;
> >  	else
> >  		mp = bip->bli_item.li_mountp;
> > @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
> >  
> >  	xfs_buf_do_callbacks(bp);
> >  	bp->b_log_item = NULL;
> > -	bp->b_li_list = NULL;
> > +	list_del_init(&bp->b_li_list);
> >  	bp->b_iodone = NULL;
> >  	xfs_buf_ioend(bp);
> >  }
> > @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
> >  bool
> >  xfs_buf_resubmit_failed_buffers(
> >  	struct xfs_buf		*bp,
> > -	struct xfs_log_item	*lip,
> >  	struct list_head	*buffer_list)
> >  {
> > -	struct xfs_log_item	*next;
> > +	struct xfs_log_item	*lip;
> >  
> >  	/*
> >  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> > @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
> >  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
> >  	 * function already have it acquired
> >  	 */
> > -	for (; lip; lip = next) {
> > -		next = lip->li_bio_list;
> > +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
> >  		xfs_clear_li_failed(lip);
> > -	}
> >  
> >  	/* Add this buffer back to the delayed write list */
> >  	return xfs_buf_delwri_queue(bp, buffer_list);
> > diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> > index 0febfbbf6ba9..643f53dcfe51 100644
> > --- a/fs/xfs/xfs_buf_item.h
> > +++ b/fs/xfs/xfs_buf_item.h
> > @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
> >  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
> >  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
> >  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> > -					struct xfs_log_item *,
> >  					struct list_head *);
> >  
> >  extern kmem_zone_t	*xfs_buf_item_zone;
> > diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> > index 664dea105e76..4a4539a4fad5 100644
> > --- a/fs/xfs/xfs_dquot_item.c
> > +++ b/fs/xfs/xfs_dquot_item.c
> > @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
> >  		if (!xfs_buf_trylock(bp))
> >  			return XFS_ITEM_LOCKED;
> >  
> > -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >  			rval = XFS_ITEM_FLUSHING;
> >  
> >  		xfs_buf_unlock(bp);
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 0a4c2e48402f..8e26d3121be6 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
> >  	struct xfs_buf		*bp;
> >  	xfs_inode_t		*ip;
> >  	xfs_inode_log_item_t	*iip;
> > -	xfs_log_item_t		*lip;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_perag	*pag;
> >  	xfs_ino_t		inum;
> >  
> > @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
> >  		 * stale first, we will not attempt to lock them in the loop
> >  		 * below as the XFS_ISTALE flag will be set.
> >  		 */
> > -		lip = bp->b_li_list;
> > -		while (lip) {
> > +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >  			if (lip->li_type == XFS_LI_INODE) {
> >  				iip = (xfs_inode_log_item_t *)lip;
> >  				ASSERT(iip->ili_logged == 1);
> > @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
> >  							&iip->ili_item.li_lsn);
> >  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
> >  			}
> > -			lip = lip->li_bio_list;
> >  		}
> >  
> >  
> > @@ -3649,7 +3647,7 @@ xfs_iflush_int(
> >  	/* generate the checksum. */
> >  	xfs_dinode_calc_crc(mp, dip);
> >  
> > -	ASSERT(bp->b_li_list != NULL);
> > +	ASSERT(!list_empty(&bp->b_li_list));
> >  	ASSERT(bp->b_iodone != NULL);
> >  	return 0;
> >  
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 993736032b4b..ddfc2c80af5e 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -521,7 +521,7 @@ xfs_inode_item_push(
> >  		if (!xfs_buf_trylock(bp))
> >  			return XFS_ITEM_LOCKED;
> >  
> > -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >  			rval = XFS_ITEM_FLUSHING;
> >  
> >  		xfs_buf_unlock(bp);
> > @@ -712,37 +712,23 @@ xfs_iflush_done(
> >  	struct xfs_log_item	*lip)
> >  {
> >  	struct xfs_inode_log_item *iip;
> > -	struct xfs_log_item	*blip;
> > -	struct xfs_log_item	*next;
> > -	struct xfs_log_item	*prev;
> > +	struct xfs_log_item	*blip, *n;
> >  	struct xfs_ail		*ailp = lip->li_ailp;
> >  	int			need_ail = 0;
> > +	LIST_HEAD(tmp);
> >  
> >  	/*
> >  	 * Scan the buffer IO completions for other inodes being completed and
> >  	 * attach them to the current inode log item.
> >  	 */
> > -	blip = bp->b_li_list;
> > -	prev = NULL;
> > -	while (blip != NULL) {
> > -		if (blip->li_cb != xfs_iflush_done) {
> > -			prev = blip;
> > -			blip = blip->li_bio_list;
> > -			continue;
> > -		}
> >  
> > -		/* remove from list */
> > -		next = blip->li_bio_list;
> > -		if (!prev) {
> > -			bp->b_li_list = next;
> > -		} else {
> > -			prev->li_bio_list = next;
> > -		}
> > +	list_add_tail(&lip->li_bio_list, &tmp);
> >  
> > -		/* add to current list */
> > -		blip->li_bio_list = lip->li_bio_list;
> > -		lip->li_bio_list = blip;
> > +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> > +		if (lip->li_cb != xfs_iflush_done)
> > +			continue;
> >  
> > +		list_move_tail(&blip->li_bio_list, &tmp);
> >  		/*
> >  		 * while we have the item, do the unlocked check for needing
> >  		 * the AIL lock.
> > @@ -751,8 +737,6 @@ xfs_iflush_done(
> >  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
> >  		    (blip->li_flags & XFS_LI_FAILED))
> >  			need_ail++;
> > -
> > -		blip = next;
> >  	}
> >  
> >  	/* make sure we capture the state of the initial inode. */
> > @@ -775,7 +759,7 @@ xfs_iflush_done(
> >  
> >  		/* this is an opencoded batch version of xfs_trans_ail_delete */
> >  		spin_lock(&ailp->xa_lock);
> > -		for (blip = lip; blip; blip = blip->li_bio_list) {
> > +		list_for_each_entry(blip, &tmp, li_bio_list) {
> >  			if (INODE_ITEM(blip)->ili_logged &&
> >  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
> >  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> > @@ -801,15 +785,14 @@ xfs_iflush_done(
> >  	 * ili_last_fields bits now that we know that the data corresponding to
> >  	 * them is safely on disk.
> >  	 */
> > -	for (blip = lip; blip; blip = next) {
> > -		next = blip->li_bio_list;
> > -		blip->li_bio_list = NULL;
> > -
> > +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> > +		list_del_init(&blip->li_bio_list);
> >  		iip = INODE_ITEM(blip);
> >  		iip->ili_logged = 0;
> >  		iip->ili_last_fields = 0;
> >  		xfs_ifunlock(iip->ili_inode);
> >  	}
> > +	list_del(&tmp);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > index 861c84e1f674..1b5082aeb538 100644
> > --- a/fs/xfs/xfs_log.c
> > +++ b/fs/xfs/xfs_log.c
> > @@ -1047,6 +1047,7 @@ xfs_log_item_init(
> >  
> >  	INIT_LIST_HEAD(&item->li_ail);
> >  	INIT_LIST_HEAD(&item->li_cil);
> > +	INIT_LIST_HEAD(&item->li_bio_list);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> > index 571fe499a48f..950cb9b4e36e 100644
> > --- a/fs/xfs/xfs_trans.h
> > +++ b/fs/xfs/xfs_trans.h
> > @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
> >  	uint				li_type;	/* item type */
> >  	uint				li_flags;	/* misc flags */
> >  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> > -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> > +	struct list_head		li_bio_list;	/* buffer item list */
> >  	void				(*li_cb)(struct xfs_buf *,
> >  						 struct xfs_log_item *);
> >  							/* buffer item iodone */
> > -- 
> > 2.14.3
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Carlos

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Buffer's log item refactoring
  2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
                   ` (3 preceding siblings ...)
  2018-01-19 14:08 ` [PATCH 4/4] Use list_head infra-structure for buffer's log items list Carlos Maiolino
@ 2018-01-19 21:43 ` Darrick J. Wong
  2018-01-20  4:54   ` Dave Chinner
  4 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-19 21:43 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

On Fri, Jan 19, 2018 at 03:08:43PM +0100, Carlos Maiolino wrote:
> Hi,
> 
> A few time ago Christoph suggested to use list_head API to handle buffer's
> log_item_list.
> 
> This patchset aims to split the current bp->b_fspriv field into a specific field
> to hold the xfs_buf_log_item, and another to hold the list of log items attached
> to the buffer (3rd patch), and finally replace the singly linked list
> implementation by the list_head infra-structure (4th patch).
> 
> The first two patches are just a typedef removal of xfs_buf_log_item_t and
> xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
> thought since we plan to get rid of the typedefs in future, this might be
> useful.
> 
> I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
> removal patches are useless, you guys call.

Typedef removal seems useful... is this series based atop current for-next?

--D

> This patchset survived several xfstests runs.
> 
> Cheers.
> 
> Carlos Maiolino (4):
>   Get rid of xfs_buf_log_item_t typedef
>   Get rid of xfs_buf_t typedef
>   Split buffer's b_fspriv field
>   Use list_head infra-structure for buffer's log items list
> 
>  fs/xfs/libxfs/xfs_alloc.c          |  36 ++++----
>  fs/xfs/libxfs/xfs_attr_leaf.c      |   2 +-
>  fs/xfs/libxfs/xfs_bmap.c           |   8 +-
>  fs/xfs/libxfs/xfs_btree.c          |  26 +++---
>  fs/xfs/libxfs/xfs_btree.h          |   2 +-
>  fs/xfs/libxfs/xfs_da_btree.c       |   2 +-
>  fs/xfs/libxfs/xfs_dir2_block.c     |   2 +-
>  fs/xfs/libxfs/xfs_dir2_data.c      |   2 +-
>  fs/xfs/libxfs/xfs_dir2_leaf.c      |   2 +-
>  fs/xfs/libxfs/xfs_dir2_node.c      |   2 +-
>  fs/xfs/libxfs/xfs_ialloc.c         |  18 ++--
>  fs/xfs/libxfs/xfs_inode_buf.c      |   4 +-
>  fs/xfs/libxfs/xfs_rtbitmap.c       |  22 ++---
>  fs/xfs/libxfs/xfs_sb.c             |   2 +-
>  fs/xfs/libxfs/xfs_symlink_remote.c |   2 +-
>  fs/xfs/xfs_buf.c                   | 140 +++++++++++++++----------------
>  fs/xfs/xfs_buf.h                   |  21 ++---
>  fs/xfs/xfs_buf_item.c              | 166 ++++++++++++++++++++-----------------
>  fs/xfs/xfs_buf_item.h              |   7 +-
>  fs/xfs/xfs_dquot.c                 |  22 ++---
>  fs/xfs/xfs_dquot_item.c            |   2 +-
>  fs/xfs/xfs_fsops.c                 |   2 +-
>  fs/xfs/xfs_inode.c                 |  24 +++---
>  fs/xfs/xfs_inode_item.c            |  41 +++------
>  fs/xfs/xfs_itable.c                |   2 +-
>  fs/xfs/xfs_log.c                   |  26 +++---
>  fs/xfs/xfs_log_recover.c           |  46 +++++-----
>  fs/xfs/xfs_qm.c                    |   8 +-
>  fs/xfs/xfs_rtalloc.c               |  20 ++---
>  fs/xfs/xfs_rtalloc.h               |   4 +-
>  fs/xfs/xfs_symlink.c               |  22 ++---
>  fs/xfs/xfs_trans.c                 |   2 +-
>  fs/xfs/xfs_trans.h                 |   4 +-
>  fs/xfs/xfs_trans_buf.c             | 104 ++++++++++++-----------
>  34 files changed, 397 insertions(+), 398 deletions(-)
> 
> -- 
> 2.14.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef
  2018-01-19 14:08 ` [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef Carlos Maiolino
@ 2018-01-20  3:33   ` Darrick J. Wong
  0 siblings, 0 replies; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-20  3:33 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

On Fri, Jan 19, 2018 at 03:08:44PM +0100, Carlos Maiolino wrote:
> Take advantage of the rework on xfs_buf log items list, to get rid of
> ths typedef for xfs_buf_log_item.
> 
> This patch also fix some indentation alignment issues found along the way.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  fs/xfs/xfs_buf_item.c  | 40 ++++++++++++++++----------------
>  fs/xfs/xfs_buf_item.h  |  6 ++---
>  fs/xfs/xfs_trans_buf.c | 62 +++++++++++++++++++++++++++-----------------------
>  3 files changed, 56 insertions(+), 52 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index e0a0af0946f2..8afcfa3ed976 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -61,14 +61,14 @@ xfs_buf_log_format_size(
>   */
>  STATIC void
>  xfs_buf_item_size_segment(
> -	struct xfs_buf_log_item	*bip,
> -	struct xfs_buf_log_format *blfp,
> -	int			*nvecs,
> -	int			*nbytes)
> +	struct xfs_buf_log_item		*bip,
> +	struct xfs_buf_log_format	*blfp,
> +	int				*nvecs,
> +	int				*nbytes)
>  {
> -	struct xfs_buf		*bp = bip->bli_buf;
> -	int			next_bit;
> -	int			last_bit;
> +	struct xfs_buf			*bp = bip->bli_buf;
> +	int				next_bit;
> +	int				last_bit;
>  
>  	last_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
>  	if (last_bit == -1)
> @@ -218,12 +218,12 @@ xfs_buf_item_format_segment(
>  	uint			offset,
>  	struct xfs_buf_log_format *blfp)
>  {
> -	struct xfs_buf	*bp = bip->bli_buf;
> -	uint		base_size;
> -	int		first_bit;
> -	int		last_bit;
> -	int		next_bit;
> -	uint		nbits;
> +	struct xfs_buf		*bp = bip->bli_buf;
> +	uint			base_size;
> +	int			first_bit;
> +	int			last_bit;
> +	int			next_bit;
> +	uint			nbits;
>  
>  	/* copy the flags across from the base format item */
>  	blfp->blf_flags = bip->__bli_format.blf_flags;
> @@ -406,10 +406,10 @@ xfs_buf_item_unpin(
>  	int			remove)
>  {
>  	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
> -	xfs_buf_t	*bp = bip->bli_buf;
> -	struct xfs_ail	*ailp = lip->li_ailp;
> -	int		stale = bip->bli_flags & XFS_BLI_STALE;
> -	int		freed;
> +	xfs_buf_t		*bp = bip->bli_buf;
> +	struct xfs_ail		*ailp = lip->li_ailp;
> +	int			stale = bip->bli_flags & XFS_BLI_STALE;
> +	int			freed;
>  
>  	ASSERT(bp->b_fspriv == bip);
>  	ASSERT(atomic_read(&bip->bli_refcount) > 0);
> @@ -880,7 +880,7 @@ xfs_buf_item_log_segment(
>   */
>  void
>  xfs_buf_item_log(
> -	xfs_buf_log_item_t	*bip,
> +	struct xfs_buf_log_item	*bip,
>  	uint			first,
>  	uint			last)
>  {
> @@ -943,7 +943,7 @@ xfs_buf_item_dirty_format(
>  
>  STATIC void
>  xfs_buf_item_free(
> -	xfs_buf_log_item_t	*bip)
> +	struct xfs_buf_log_item	*bip)
>  {
>  	xfs_buf_item_free_format(bip);
>  	kmem_free(bip->bli_item.li_lv_shadow);
> @@ -961,7 +961,7 @@ void
>  xfs_buf_item_relse(
>  	xfs_buf_t	*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	trace_xfs_buf_item_relse(bp, _RET_IP_);
>  	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> index 9690ce62c9a7..0febfbbf6ba9 100644
> --- a/fs/xfs/xfs_buf_item.h
> +++ b/fs/xfs/xfs_buf_item.h
> @@ -50,7 +50,7 @@ struct xfs_buf_log_item;
>   * needed to log buffers.  It tracks how many times the lock has been
>   * locked, and which 128 byte chunks of the buffer are dirty.
>   */
> -typedef struct xfs_buf_log_item {
> +struct xfs_buf_log_item {
>  	xfs_log_item_t		bli_item;	/* common item structure */
>  	struct xfs_buf		*bli_buf;	/* real buffer pointer */
>  	unsigned int		bli_flags;	/* misc flags */
> @@ -59,11 +59,11 @@ typedef struct xfs_buf_log_item {
>  	int			bli_format_count;	/* count of headers */
>  	struct xfs_buf_log_format *bli_formats;	/* array of in-log header ptrs */
>  	struct xfs_buf_log_format __bli_format;	/* embedded in-log header */
> -} xfs_buf_log_item_t;
> +};
>  
>  int	xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
>  void	xfs_buf_item_relse(struct xfs_buf *);
> -void	xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
> +void	xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
>  bool	xfs_buf_item_dirty_format(struct xfs_buf_log_item *);
>  void	xfs_buf_attach_iodone(struct xfs_buf *,
>  			      void(*)(struct xfs_buf *, xfs_log_item_t *),
> diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
> index 3ba7a96a8abd..74563cd2970c 100644
> --- a/fs/xfs/xfs_trans_buf.c
> +++ b/fs/xfs/xfs_trans_buf.c
> @@ -139,7 +139,7 @@ xfs_trans_get_buf_map(
>  	xfs_buf_flags_t		flags)
>  {
>  	xfs_buf_t		*bp;
> -	xfs_buf_log_item_t	*bip;
> +	struct xfs_buf_log_item	*bip;
>  
>  	if (!tp)
>  		return xfs_buf_get_map(target, map, nmaps, flags);
> @@ -188,12 +188,13 @@ xfs_trans_get_buf_map(
>   * mount structure.
>   */
>  xfs_buf_t *
> -xfs_trans_getsb(xfs_trans_t	*tp,
> -		struct xfs_mount *mp,
> -		int		flags)
> +xfs_trans_getsb(
> +	xfs_trans_t		*tp,
> +	struct xfs_mount	*mp,
> +	int			flags)
>  {
>  	xfs_buf_t		*bp;
> -	xfs_buf_log_item_t	*bip;
> +	struct xfs_buf_log_item	*bip;
>  
>  	/*
>  	 * Default to just trying to lock the superblock buffer
> @@ -352,10 +353,11 @@ xfs_trans_read_buf_map(
>   * brelse() call.
>   */
>  void
> -xfs_trans_brelse(xfs_trans_t	*tp,
> -		 xfs_buf_t	*bp)
> +xfs_trans_brelse(
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip;
> +	struct xfs_buf_log_item	*bip;
>  	int			freed;
>  
>  	/*
> @@ -456,10 +458,11 @@ xfs_trans_brelse(xfs_trans_t	*tp,
>   */
>  /* ARGSUSED */
>  void
> -xfs_trans_bhold(xfs_trans_t	*tp,
> -		xfs_buf_t	*bp)
> +xfs_trans_bhold(
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	ASSERT(bp->b_transp == tp);
>  	ASSERT(bip != NULL);
> @@ -476,10 +479,11 @@ xfs_trans_bhold(xfs_trans_t	*tp,
>   * for this transaction.
>   */
>  void
> -xfs_trans_bhold_release(xfs_trans_t	*tp,
> -			xfs_buf_t	*bp)
> +xfs_trans_bhold_release(
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	ASSERT(bp->b_transp == tp);
>  	ASSERT(bip != NULL);
> @@ -600,10 +604,10 @@ xfs_trans_log_buf(
>   */
>  void
>  xfs_trans_binval(
> -	xfs_trans_t	*tp,
> -	xfs_buf_t	*bp)
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  	int			i;
>  
>  	ASSERT(bp->b_transp == tp);
> @@ -655,10 +659,10 @@ xfs_trans_binval(
>   */
>  void
>  xfs_trans_inode_buf(
> -	xfs_trans_t	*tp,
> -	xfs_buf_t	*bp)
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	ASSERT(bp->b_transp == tp);
>  	ASSERT(bip != NULL);
> @@ -679,10 +683,10 @@ xfs_trans_inode_buf(
>   */
>  void
>  xfs_trans_stale_inode_buf(
> -	xfs_trans_t	*tp,
> -	xfs_buf_t	*bp)
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	ASSERT(bp->b_transp == tp);
>  	ASSERT(bip != NULL);
> @@ -704,10 +708,10 @@ xfs_trans_stale_inode_buf(
>  /* ARGSUSED */
>  void
>  xfs_trans_inode_alloc_buf(
> -	xfs_trans_t	*tp,
> -	xfs_buf_t	*bp)
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp)
>  {
> -	xfs_buf_log_item_t	*bip = bp->b_fspriv;
> +	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
>  	ASSERT(bp->b_transp == tp);
>  	ASSERT(bip != NULL);
> @@ -797,9 +801,9 @@ xfs_trans_buf_copy_type(
>  /* ARGSUSED */
>  void
>  xfs_trans_dquot_buf(
> -	xfs_trans_t	*tp,
> -	xfs_buf_t	*bp,
> -	uint		type)
> +	xfs_trans_t		*tp,
> +	xfs_buf_t		*bp,
> +	uint			type)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> -- 
> 2.14.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/4] Get rid of xfs_buf_t typedef
  2018-01-19 14:08 ` [PATCH 2/4] Get rid of xfs_buf_t typedef Carlos Maiolino
@ 2018-01-20  3:35   ` Darrick J. Wong
  0 siblings, 0 replies; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-20  3:35 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

On Fri, Jan 19, 2018 at 03:08:45PM +0100, Carlos Maiolino wrote:
> Took advantage from my rework on bp->b_fspriv to get rid of the
> xfs_buf_t typedef.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  fs/xfs/libxfs/xfs_alloc.c     |  32 +++++-----
>  fs/xfs/libxfs/xfs_bmap.c      |   8 +--
>  fs/xfs/libxfs/xfs_btree.c     |  22 +++----
>  fs/xfs/libxfs/xfs_btree.h     |   2 +-
>  fs/xfs/libxfs/xfs_ialloc.c    |  16 ++---
>  fs/xfs/libxfs/xfs_inode_buf.c |   4 +-
>  fs/xfs/libxfs/xfs_rtbitmap.c  |  22 +++----
>  fs/xfs/xfs_buf.c              | 139 +++++++++++++++++++++---------------------
>  fs/xfs/xfs_buf.h              |  18 +++---
>  fs/xfs/xfs_buf_item.c         |   8 +--
>  fs/xfs/xfs_dquot.c            |  22 +++----
>  fs/xfs/xfs_fsops.c            |   2 +-
>  fs/xfs/xfs_inode.c            |  16 ++---
>  fs/xfs/xfs_itable.c           |   2 +-
>  fs/xfs/xfs_log.c              |  17 +++---
>  fs/xfs/xfs_log_recover.c      |  40 ++++++------
>  fs/xfs/xfs_qm.c               |   8 +--
>  fs/xfs/xfs_rtalloc.c          |  20 +++---
>  fs/xfs/xfs_rtalloc.h          |   4 +-
>  fs/xfs/xfs_symlink.c          |  22 +++----
>  fs/xfs/xfs_trans.c            |   2 +-
>  fs/xfs/xfs_trans.h            |   2 +-
>  fs/xfs/xfs_trans_buf.c        |  22 +++----
>  23 files changed, 225 insertions(+), 225 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 50ba989481cc..b41999fcbbe0 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -590,7 +590,7 @@ static void
>  xfs_agfl_write_verify(
>  	struct xfs_buf	*bp)
>  {
> -	struct xfs_mount *mp = bp->b_target->bt_mount;
> +	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  	xfs_failaddr_t		fa;
>  
> @@ -625,9 +625,9 @@ xfs_alloc_read_agfl(
>  	xfs_mount_t	*mp,		/* mount point structure */
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_agnumber_t	agno,		/* allocation group number */
> -	xfs_buf_t	**bpp)		/* buffer for the ag free block array */
> +	struct xfs_buf	**bpp)		/* buffer for the ag free block array */
>  {
> -	xfs_buf_t	*bp;		/* return value */
> +	struct xfs_buf	*bp;		/* return value */
>  	int		error;
>  
>  	ASSERT(agno != NULLAGNUMBER);
> @@ -1594,7 +1594,7 @@ xfs_alloc_ag_vextent_small(
>  			      xfs_alloc_allow_busy_reuse(args->datatype));
>  
>  			if (xfs_alloc_is_userdata(args->datatype)) {
> -				xfs_buf_t	*bp;
> +				struct xfs_buf	*bp;
>  
>  				bp = xfs_btree_get_bufs(args->mp, args->tp,
>  					args->agno, fbno, 0);
> @@ -1670,7 +1670,7 @@ xfs_alloc_ag_vextent_small(
>  STATIC int
>  xfs_free_ag_extent(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*agbp,
> +	struct xfs_buf		*agbp,
>  	xfs_agnumber_t		agno,
>  	xfs_agblock_t		bno,
>  	xfs_extlen_t		len,
> @@ -2229,12 +2229,12 @@ xfs_alloc_fix_freelist(
>  int				/* error */
>  xfs_alloc_get_freelist(
>  	xfs_trans_t	*tp,	/* transaction pointer */
> -	xfs_buf_t	*agbp,	/* buffer containing the agf structure */
> +	struct xfs_buf	*agbp,	/* buffer containing the agf structure */
>  	xfs_agblock_t	*bnop,	/* block address retrieved from freelist */
>  	int		btreeblk) /* destination is a AGF btree */
>  {
>  	xfs_agf_t	*agf;	/* a.g. freespace structure */
> -	xfs_buf_t	*agflbp;/* buffer for a.g. freelist structure */
> +	struct xfs_buf	*agflbp;/* buffer for a.g. freelist structure */
>  	xfs_agblock_t	bno;	/* block number returned */
>  	__be32		*agfl_bno;
>  	int		error;
> @@ -2294,7 +2294,7 @@ xfs_alloc_get_freelist(
>  void
>  xfs_alloc_log_agf(
>  	xfs_trans_t	*tp,	/* transaction pointer */
> -	xfs_buf_t	*bp,	/* buffer for a.g. freelist header */
> +	struct xfs_buf	*bp,	/* buffer for a.g. freelist header */
>  	int		fields)	/* mask of fields to be logged (XFS_AGF_...) */
>  {
>  	int	first;		/* first byte offset */
> @@ -2340,7 +2340,7 @@ xfs_alloc_pagf_init(
>  	xfs_agnumber_t		agno,	/* allocation group number */
>  	int			flags)	/* XFS_ALLOC_FLAGS_... */
>  {
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			error;
>  
>  	if ((error = xfs_alloc_read_agf(mp, tp, agno, flags, &bp)))
> @@ -2356,8 +2356,8 @@ xfs_alloc_pagf_init(
>  int					/* error */
>  xfs_alloc_put_freelist(
>  	xfs_trans_t		*tp,	/* transaction pointer */
> -	xfs_buf_t		*agbp,	/* buffer for a.g. freelist header */
> -	xfs_buf_t		*agflbp,/* buffer for a.g. free block array */
> +	struct xfs_buf		*agbp,	/* buffer for a.g. freelist header */
> +	struct xfs_buf		*agflbp,/* buffer for a.g. free block array */
>  	xfs_agblock_t		bno,	/* block being freed */
>  	int			btreeblk) /* block came from a AGF btree */
>  {
> @@ -2468,10 +2468,10 @@ xfs_agf_verify(
>  
>  static void
>  xfs_agf_read_verify(
> -	struct xfs_buf	*bp)
> +	struct xfs_buf		*bp)
>  {
> -	struct xfs_mount *mp = bp->b_target->bt_mount;
> -	xfs_failaddr_t	fa;
> +	struct xfs_mount	*mp = bp->b_target->bt_mount;
> +	xfs_failaddr_t		fa;
>  
>  	if (xfs_sb_version_hascrc(&mp->m_sb) &&
>  	    !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
> @@ -2485,9 +2485,9 @@ xfs_agf_read_verify(
>  
>  static void
>  xfs_agf_write_verify(
> -	struct xfs_buf	*bp)
> +	struct xfs_buf		*bp)
>  {
> -	struct xfs_mount *mp = bp->b_target->bt_mount;
> +	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  	xfs_failaddr_t		fa;
>  
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 140744700b07..651eb4639713 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -334,7 +334,7 @@ xfs_bmap_check_leaf_extents(
>  {
>  	struct xfs_btree_block	*block;	/* current btree block */
>  	xfs_fsblock_t		bno;	/* block # of "block" */
> -	xfs_buf_t		*bp;	/* buffer for "block" */
> +	struct xfs_buf		*bp;	/* buffer for "block" */
>  	int			error;	/* error return value */
>  	xfs_extnum_t		i=0, j;	/* index into the extents list */
>  	xfs_ifork_t		*ifp;	/* fork structure */
> @@ -600,7 +600,7 @@ xfs_bmap_btree_to_extents(
>  	/* REFERENCED */
>  	struct xfs_btree_block	*cblock;/* child btree block */
>  	xfs_fsblock_t		cbno;	/* child block number */
> -	xfs_buf_t		*cbp;	/* child block's buffer */
> +	struct xfs_buf		*cbp;	/* child block's buffer */
>  	int			error;	/* error return value */
>  	xfs_ifork_t		*ifp;	/* inode fork data */
>  	xfs_mount_t		*mp;	/* mount point structure */
> @@ -662,7 +662,7 @@ xfs_bmap_extents_to_btree(
>  	int			whichfork)	/* data or attr fork */
>  {
>  	struct xfs_btree_block	*ablock;	/* allocated (child) bt block */
> -	xfs_buf_t		*abp;		/* buffer for ablock */
> +	struct xfs_buf		*abp;		/* buffer for ablock */
>  	xfs_alloc_arg_t		args;		/* allocation arguments */
>  	xfs_bmbt_rec_t		*arp;		/* child record pointer */
>  	struct xfs_btree_block	*block;		/* btree root block */
> @@ -829,7 +829,7 @@ xfs_bmap_local_to_extents(
>  	int		flags;		/* logging flags returned */
>  	xfs_ifork_t	*ifp;		/* inode fork pointer */
>  	xfs_alloc_arg_t	args;		/* allocation arguments */
> -	xfs_buf_t	*bp;		/* buffer for extent block */
> +	struct xfs_buf	*bp;		/* buffer for extent block */
>  	struct xfs_bmbt_irec rec;
>  	struct xfs_iext_cursor icur;
>  
> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
> index 2b2be1d6c00d..cc501b7d1fc5 100644
> --- a/fs/xfs/libxfs/xfs_btree.c
> +++ b/fs/xfs/libxfs/xfs_btree.c
> @@ -398,7 +398,7 @@ xfs_btree_dup_cursor(
>  	xfs_btree_cur_t	*cur,		/* input cursor */
>  	xfs_btree_cur_t	**ncur)		/* output cursor */
>  {
> -	xfs_buf_t	*bp;		/* btree block's buffer pointer */
> +	struct xfs_buf	*bp;		/* btree block's buffer pointer */
>  	int		error;		/* error return value */
>  	int		i;		/* level number of btree block */
>  	xfs_mount_t	*mp;		/* mount structure for filesystem */
> @@ -686,14 +686,14 @@ xfs_btree_get_block(
>   * Get a buffer for the block, return it with no data read.
>   * Long-form addressing.
>   */
> -xfs_buf_t *				/* buffer for fsbno */
> +struct xfs_buf *			/* buffer for fsbno */
>  xfs_btree_get_bufl(
>  	xfs_mount_t	*mp,		/* file system mount point */
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_fsblock_t	fsbno,		/* file system block number */
>  	uint		lock)		/* lock flags for get_buf */
>  {
> -	xfs_daddr_t		d;		/* real disk block address */
> +	xfs_daddr_t	d;		/* real disk block address */
>  
>  	ASSERT(fsbno != NULLFSBLOCK);
>  	d = XFS_FSB_TO_DADDR(mp, fsbno);
> @@ -704,7 +704,7 @@ xfs_btree_get_bufl(
>   * Get a buffer for the block, return it with no data read.
>   * Short-form addressing.
>   */
> -xfs_buf_t *				/* buffer for agno/agbno */
> +struct xfs_buf *			/* buffer for agno/agbno */
>  xfs_btree_get_bufs(
>  	xfs_mount_t	*mp,		/* file system mount point */
>  	xfs_trans_t	*tp,		/* transaction pointer */
> @@ -712,7 +712,7 @@ xfs_btree_get_bufs(
>  	xfs_agblock_t	agbno,		/* allocation group block number */
>  	uint		lock)		/* lock flags for get_buf */
>  {
> -	xfs_daddr_t		d;		/* real disk block address */
> +	xfs_daddr_t	d;		/* real disk block address */
>  
>  	ASSERT(agno != NULLAGNUMBER);
>  	ASSERT(agbno != NULLAGBLOCK);
> @@ -729,7 +729,7 @@ xfs_btree_islastblock(
>  	int			level)	/* level to check */
>  {
>  	struct xfs_btree_block	*block;	/* generic btree block pointer */
> -	xfs_buf_t		*bp;	/* buffer containing block */
> +	struct xfs_buf		*bp;	/* buffer containing block */
>  
>  	block = xfs_btree_get_block(cur, level, &bp);
>  	xfs_btree_check_block(cur, block, level, bp);
> @@ -749,7 +749,7 @@ xfs_btree_firstrec(
>  	int			level)	/* level to change */
>  {
>  	struct xfs_btree_block	*block;	/* generic btree block pointer */
> -	xfs_buf_t		*bp;	/* buffer containing block */
> +	struct xfs_buf		*bp;	/* buffer containing block */
>  
>  	/*
>  	 * Get the block pointer for this level.
> @@ -779,7 +779,7 @@ xfs_btree_lastrec(
>  	int			level)	/* level to change */
>  {
>  	struct xfs_btree_block	*block;	/* generic btree block pointer */
> -	xfs_buf_t		*bp;	/* buffer containing block */
> +	struct xfs_buf		*bp;	/* buffer containing block */
>  
>  	/*
>  	 * Get the block pointer for this level.
> @@ -1031,7 +1031,7 @@ STATIC void
>  xfs_btree_setbuf(
>  	xfs_btree_cur_t		*cur,	/* btree cursor */
>  	int			lev,	/* level in btree */
> -	xfs_buf_t		*bp)	/* new buffer to set */
> +	struct xfs_buf		*bp)	/* new buffer to set */
>  {
>  	struct xfs_btree_block	*b;	/* btree block */
>  
> @@ -1696,7 +1696,7 @@ xfs_btree_decrement(
>  	int			*stat)		/* success/failure */
>  {
>  	struct xfs_btree_block	*block;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			error;		/* error return value */
>  	int			lev;
>  	union xfs_btree_ptr	ptr;
> @@ -3230,7 +3230,7 @@ xfs_btree_make_block_unfull(
>  
>  	if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) &&
>  	    level == cur->bc_nlevels - 1) {
> -	    	struct xfs_inode *ip = cur->bc_private.b.ip;
> +		struct xfs_inode *ip = cur->bc_private.b.ip;
>  
>  		if (numrecs < cur->bc_ops->get_dmaxrecs(cur, level)) {
>  			/* A root block that can be made bigger. */
> diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
> index 2f13b8676f41..31df5935d6ab 100644
> --- a/fs/xfs/libxfs/xfs_btree.h
> +++ b/fs/xfs/libxfs/xfs_btree.h
> @@ -478,7 +478,7 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
>   * over to the generic tracing functionality, which is some effort.
>   *
>   * i,j = integer (32 bit)
> - * b = btree block buffer (xfs_buf_t)
> + * b = btree block buffer (struct xfs_buf)
>   * p = btree ptr
>   * r = btree record
>   * k = btree key
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index c01ed9cfc5ae..1580912fe5a2 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -604,7 +604,7 @@ xfs_inobt_insert_sprec(
>  STATIC int				/* error code or 0 */
>  xfs_ialloc_ag_alloc(
>  	xfs_trans_t	*tp,		/* transaction pointer */
> -	xfs_buf_t	*agbp,		/* alloc group buffer */
> +	struct xfs_buf	*agbp,		/* alloc group buffer */
>  	int		*alloc)
>  {
>  	xfs_agi_t	*agi;		/* allocation group header */
> @@ -2127,9 +2127,9 @@ xfs_difree_finobt(
>   */
>  int
>  xfs_difree(
> -	struct xfs_trans	*tp,		/* transaction pointer */
> -	xfs_ino_t		inode,		/* inode to be freed */
> -	struct xfs_defer_ops	*dfops,		/* extents to free */
> +	struct xfs_trans	*tp,	/* transaction pointer */
> +	xfs_ino_t		inode,	/* inode to be freed */
> +	struct xfs_defer_ops	*dfops,	/* extents to free */
>  	struct xfs_icluster	*xic)	/* cluster info if deleted */
>  {
>  	/* REFERENCED */
> @@ -2425,7 +2425,7 @@ xfs_ialloc_compute_maxlevels(
>  void
>  xfs_ialloc_log_agi(
>  	xfs_trans_t	*tp,		/* transaction pointer */
> -	xfs_buf_t	*bp,		/* allocation group header buffer */
> +	struct xfs_buf	*bp,		/* allocation group header buffer */
>  	int		fields)		/* bitmask of fields to log */
>  {
>  	int			first;		/* first byte number */
> @@ -2555,9 +2555,9 @@ xfs_agi_read_verify(
>  
>  static void
>  xfs_agi_write_verify(
> -	struct xfs_buf	*bp)
> +	struct xfs_buf		*bp)
>  {
> -	struct xfs_mount *mp = bp->b_target->bt_mount;
> +	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  	xfs_failaddr_t		fa;
>  
> @@ -2653,7 +2653,7 @@ xfs_ialloc_pagi_init(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_agnumber_t	agno)		/* allocation group number */
>  {
> -	xfs_buf_t	*bp = NULL;
> +	struct xfs_buf	*bp = NULL;
>  	int		error;
>  
>  	error = xfs_ialloc_read_agi(mp, tp, agno, &bp);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 4035b5d5f6fd..ae1f58e19e49 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -40,7 +40,7 @@
>  void
>  xfs_inobp_check(
>  	xfs_mount_t	*mp,
> -	xfs_buf_t	*bp)
> +	struct xfs_buf	*bp)
>  {
>  	int		i;
>  	int		j;
> @@ -542,7 +542,7 @@ xfs_iread(
>  	xfs_inode_t	*ip,
>  	uint		iget_flags)
>  {
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	xfs_dinode_t	*dip;
>  	xfs_failaddr_t	fa;
>  	int		error;
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index 3fb29a5ea915..f6b94eb191c8 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -76,9 +76,9 @@ xfs_rtbuf_get(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_rtblock_t	block,		/* block number in bitmap or summary */
>  	int		issum,		/* is summary not bitmap */
> -	xfs_buf_t	**bpp)		/* output: buffer for the block */
> +	struct xfs_buf	**bpp)		/* output: buffer for the block */
>  {
> -	xfs_buf_t	*bp;		/* block buffer, result */
> +	struct xfs_buf	*bp;		/* block buffer, result */
>  	xfs_inode_t	*ip;		/* bitmap or summary inode */
>  	xfs_bmbt_irec_t	map;
>  	int		nmap = 1;
> @@ -118,7 +118,7 @@ xfs_rtfind_back(
>  	xfs_rtword_t	*b;		/* current word in buffer */
>  	int		bit;		/* bit number in the word */
>  	xfs_rtblock_t	block;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* buf for the block */
> +	struct xfs_buf	*bp;		/* buf for the block */
>  	xfs_rtword_t	*bufp;		/* starting word in buffer */
>  	int		error;		/* error value */
>  	xfs_rtblock_t	firstbit;	/* first useful bit in the word */
> @@ -293,7 +293,7 @@ xfs_rtfind_forw(
>  	xfs_rtword_t	*b;		/* current word in buffer */
>  	int		bit;		/* bit number in the word */
>  	xfs_rtblock_t	block;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* buf for the block */
> +	struct xfs_buf	*bp;		/* buf for the block */
>  	xfs_rtword_t	*bufp;		/* starting word in buffer */
>  	int		error;		/* error value */
>  	xfs_rtblock_t	i;		/* current bit number rel. to start */
> @@ -464,11 +464,11 @@ xfs_rtmodify_summary_int(
>  	int		log,		/* log2 of extent size */
>  	xfs_rtblock_t	bbno,		/* bitmap block number */
>  	int		delta,		/* change to make to summary info */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_suminfo_t	*sum)		/* out: summary info for this block */
>  {
> -	xfs_buf_t	*bp;		/* buffer for the summary block */
> +	struct xfs_buf	*bp;		/* buffer for the summary block */
>  	int		error;		/* error value */
>  	xfs_fsblock_t	sb;		/* summary fsblock */
>  	int		so;		/* index into the summary file */
> @@ -528,7 +528,7 @@ xfs_rtmodify_summary(
>  	int		log,		/* log2 of extent size */
>  	xfs_rtblock_t	bbno,		/* bitmap block number */
>  	int		delta,		/* change to make to summary info */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
>  {
>  	return xfs_rtmodify_summary_int(mp, tp, log, bbno,
> @@ -550,7 +550,7 @@ xfs_rtmodify_range(
>  	xfs_rtword_t	*b;		/* current word in buffer */
>  	int		bit;		/* bit number in the word */
>  	xfs_rtblock_t	block;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* buf for the block */
> +	struct xfs_buf	*bp;		/* buf for the block */
>  	xfs_rtword_t	*bufp;		/* starting word in buffer */
>  	int		error;		/* error value */
>  	xfs_rtword_t	*first;		/* first used word in the buffer */
> @@ -701,7 +701,7 @@ xfs_rtfree_range(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_rtblock_t	start,		/* starting block to free */
>  	xfs_extlen_t	len,		/* length to free */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
>  {
>  	xfs_rtblock_t	end;		/* end of the freed extent */
> @@ -784,7 +784,7 @@ xfs_rtcheck_range(
>  	xfs_rtword_t	*b;		/* current word in buffer */
>  	int		bit;		/* bit number in the word */
>  	xfs_rtblock_t	block;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* buf for the block */
> +	struct xfs_buf	*bp;		/* buf for the block */
>  	xfs_rtword_t	*bufp;		/* starting word in buffer */
>  	int		error;		/* error value */
>  	xfs_rtblock_t	i;		/* current bit number rel. to start */
> @@ -980,7 +980,7 @@ xfs_rtfree_extent(
>  	int		error;		/* error value */
>  	xfs_mount_t	*mp;		/* file system mount structure */
>  	xfs_fsblock_t	sb;		/* summary file block number */
> -	xfs_buf_t	*sumbp = NULL;	/* summary file block buffer */
> +	struct xfs_buf	*sumbp = NULL;	/* summary file block buffer */
>  
>  	mp = tp->t_mountp;
>  
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 1981ef77040d..07dccb05e782 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -179,8 +179,8 @@ xfs_buf_stale(
>  
>  static int
>  xfs_buf_get_maps(
> -	struct xfs_buf		*bp,
> -	int			map_count)
> +	struct xfs_buf	*bp,
> +	int		map_count)
>  {
>  	ASSERT(bp->b_maps == NULL);
>  	bp->b_map_count = map_count;
> @@ -277,8 +277,8 @@ _xfs_buf_alloc(
>   */
>  STATIC int
>  _xfs_buf_get_pages(
> -	xfs_buf_t		*bp,
> -	int			page_count)
> +	struct xfs_buf	*bp,
> +	int		page_count)
>  {
>  	/* Make sure that we have a page list */
>  	if (bp->b_pages == NULL) {
> @@ -301,7 +301,7 @@ _xfs_buf_get_pages(
>   */
>  STATIC void
>  _xfs_buf_free_pages(
> -	xfs_buf_t	*bp)
> +	struct xfs_buf	*bp)
>  {
>  	if (bp->b_pages != bp->b_page_array) {
>  		kmem_free(bp->b_pages);
> @@ -312,13 +312,13 @@ _xfs_buf_free_pages(
>  /*
>   *	Releases the specified buffer.
>   *
> - * 	The modification state of any associated pages is left unchanged.
> - * 	The buffer must not be on any hash - use xfs_buf_rele instead for
> - * 	hashed and refcounted buffers
> + *	The modification state of any associated pages is left unchanged.
> + *	The buffer must not be on any hash - use xfs_buf_rele instead for
> + *	hashed and refcounted buffers
>   */
>  void
>  xfs_buf_free(
> -	xfs_buf_t		*bp)
> +	struct xfs_buf	*bp)
>  {
>  	trace_xfs_buf_free(bp, _RET_IP_);
>  
> @@ -348,15 +348,15 @@ xfs_buf_free(
>   */
>  STATIC int
>  xfs_buf_allocate_memory(
> -	xfs_buf_t		*bp,
> -	uint			flags)
> -{
> -	size_t			size;
> -	size_t			nbytes, offset;
> -	gfp_t			gfp_mask = xb_to_gfp(flags);
> -	unsigned short		page_count, i;
> -	xfs_off_t		start, end;
> -	int			error;
> +	struct xfs_buf	*bp,
> +	uint		flags)
> +{
> +	size_t		size;
> +	size_t		nbytes, offset;
> +	gfp_t		gfp_mask = xb_to_gfp(flags);
> +	unsigned short	page_count, i;
> +	xfs_off_t	start, end;
> +	int		error;
>  
>  	/*
>  	 * for buffers that are contained within a single page, just allocate
> @@ -448,8 +448,8 @@ xfs_buf_allocate_memory(
>   */
>  STATIC int
>  _xfs_buf_map_pages(
> -	xfs_buf_t		*bp,
> -	uint			flags)
> +	struct xfs_buf	*bp,
> +	uint		flags)
>  {
>  	ASSERT(bp->b_flags & _XBF_PAGES);
>  	if (bp->b_page_count == 1) {
> @@ -552,16 +552,16 @@ xfs_buf_hash_destroy(
>   *	a given range of an inode.  The buffer is returned
>   *	locked.	No I/O is implied by this call.
>   */
> -xfs_buf_t *
> +struct xfs_buf *
>  _xfs_buf_find(
>  	struct xfs_buftarg	*btp,
>  	struct xfs_buf_map	*map,
>  	int			nmaps,
>  	xfs_buf_flags_t		flags,
> -	xfs_buf_t		*new_bp)
> +	struct xfs_buf		*new_bp)
>  {
>  	struct xfs_perag	*pag;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	struct xfs_buf_map	cmap = { .bm_bn = map[0].bm_bn };
>  	xfs_daddr_t		eofs;
>  	int			i;
> @@ -712,8 +712,8 @@ xfs_buf_get_map(
>  
>  STATIC int
>  _xfs_buf_read(
> -	xfs_buf_t		*bp,
> -	xfs_buf_flags_t		flags)
> +	struct xfs_buf	*bp,
> +	xfs_buf_flags_t	flags)
>  {
>  	ASSERT(!(flags & XBF_WRITE));
>  	ASSERT(bp->b_maps[0].bm_bn != XFS_BUF_DADDR_NULL);
> @@ -728,7 +728,7 @@ _xfs_buf_read(
>  	return xfs_buf_submit_wait(bp);
>  }
>  
> -xfs_buf_t *
> +struct xfs_buf *
>  xfs_buf_read_map(
>  	struct xfs_buftarg	*target,
>  	struct xfs_buf_map	*map,
> @@ -827,8 +827,8 @@ xfs_buf_read_uncached(
>   */
>  void
>  xfs_buf_set_empty(
> -	struct xfs_buf		*bp,
> -	size_t			numblks)
> +	struct xfs_buf	*bp,
> +	size_t		numblks)
>  {
>  	if (bp->b_pages)
>  		_xfs_buf_free_pages(bp);
> @@ -858,16 +858,16 @@ mem_to_page(
>  
>  int
>  xfs_buf_associate_memory(
> -	xfs_buf_t		*bp,
> -	void			*mem,
> -	size_t			len)
> +	struct xfs_buf	*bp,
> +	void		*mem,
> +	size_t		len)
>  {
> -	int			rval;
> -	int			i = 0;
> -	unsigned long		pageaddr;
> -	unsigned long		offset;
> -	size_t			buflen;
> -	int			page_count;
> +	int		rval;
> +	int		i = 0;
> +	unsigned long	pageaddr;
> +	unsigned long	offset;
> +	size_t		buflen;
> +	int		page_count;
>  
>  	pageaddr = (unsigned long)mem & PAGE_MASK;
>  	offset = (unsigned long)mem - pageaddr;
> @@ -898,7 +898,7 @@ xfs_buf_associate_memory(
>  	return 0;
>  }
>  
> -xfs_buf_t *
> +struct xfs_buf *
>  xfs_buf_get_uncached(
>  	struct xfs_buftarg	*target,
>  	size_t			numblks,
> @@ -954,7 +954,7 @@ xfs_buf_get_uncached(
>   */
>  void
>  xfs_buf_hold(
> -	xfs_buf_t		*bp)
> +	struct xfs_buf	*bp)
>  {
>  	trace_xfs_buf_hold(bp, _RET_IP_);
>  	atomic_inc(&bp->b_hold);
> @@ -966,7 +966,7 @@ xfs_buf_hold(
>   */
>  void
>  xfs_buf_rele(
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_perag	*pag = bp->b_pag;
>  	bool			release;
> @@ -1054,9 +1054,9 @@ xfs_buf_rele(
>   */
>  int
>  xfs_buf_trylock(
> -	struct xfs_buf		*bp)
> +	struct xfs_buf	*bp)
>  {
> -	int			locked;
> +	int		locked;
>  
>  	locked = down_trylock(&bp->b_sema) == 0;
>  	if (locked) {
> @@ -1079,7 +1079,7 @@ xfs_buf_trylock(
>   */
>  void
>  xfs_buf_lock(
> -	struct xfs_buf		*bp)
> +	struct xfs_buf	*bp)
>  {
>  	trace_xfs_buf_lock(bp, _RET_IP_);
>  
> @@ -1093,7 +1093,7 @@ xfs_buf_lock(
>  
>  void
>  xfs_buf_unlock(
> -	struct xfs_buf		*bp)
> +	struct xfs_buf	*bp)
>  {
>  	ASSERT(xfs_buf_islocked(bp));
>  
> @@ -1105,7 +1105,7 @@ xfs_buf_unlock(
>  
>  STATIC void
>  xfs_buf_wait_unpin(
> -	xfs_buf_t		*bp)
> +	struct xfs_buf	*bp)
>  {
>  	DECLARE_WAITQUEUE	(wait, current);
>  
> @@ -1165,8 +1165,7 @@ static void
>  xfs_buf_ioend_work(
>  	struct work_struct	*work)
>  {
> -	struct xfs_buf		*bp =
> -		container_of(work, xfs_buf_t, b_ioend_work);
> +	struct xfs_buf	*bp = container_of(work, struct xfs_buf, b_ioend_work);
>  
>  	xfs_buf_ioend(bp);
>  }
> @@ -1181,9 +1180,9 @@ xfs_buf_ioend_async(
>  
>  void
>  __xfs_buf_ioerror(
> -	xfs_buf_t		*bp,
> -	int			error,
> -	xfs_failaddr_t		failaddr)
> +	struct xfs_buf	*bp,
> +	int		error,
> +	xfs_failaddr_t	failaddr)
>  {
>  	ASSERT(error <= 0 && error >= -1000);
>  	bp->b_error = error;
> @@ -1192,8 +1191,8 @@ __xfs_buf_ioerror(
>  
>  void
>  xfs_buf_ioerror_alert(
> -	struct xfs_buf		*bp,
> -	const char		*func)
> +	struct xfs_buf	*bp,
> +	const char	*func)
>  {
>  	xfs_alert(bp->b_target->bt_mount,
>  "metadata I/O error: block 0x%llx (\"%s\") error %d numblks %d",
> @@ -1202,9 +1201,9 @@ xfs_buf_ioerror_alert(
>  
>  int
>  xfs_bwrite(
> -	struct xfs_buf		*bp)
> +	struct xfs_buf	*bp)
>  {
> -	int			error;
> +	int		error;
>  
>  	ASSERT(xfs_buf_islocked(bp));
>  
> @@ -1222,9 +1221,9 @@ xfs_bwrite(
>  
>  static void
>  xfs_buf_bio_end_io(
> -	struct bio		*bio)
> +	struct bio	*bio)
>  {
> -	struct xfs_buf		*bp = (struct xfs_buf *)bio->bi_private;
> +	struct xfs_buf	*bp = (struct xfs_buf *)bio->bi_private;
>  
>  	/*
>  	 * don't overwrite existing errors - otherwise we can lose errors on
> @@ -1545,10 +1544,10 @@ xfs_buf_submit_wait(
>  
>  void *
>  xfs_buf_offset(
> -	struct xfs_buf		*bp,
> -	size_t			offset)
> +	struct xfs_buf	*bp,
> +	size_t		offset)
>  {
> -	struct page		*page;
> +	struct page	*page;
>  
>  	if (bp->b_addr)
>  		return bp->b_addr + offset;
> @@ -1563,13 +1562,13 @@ xfs_buf_offset(
>   */
>  void
>  xfs_buf_iomove(
> -	xfs_buf_t		*bp,	/* buffer to process		*/
> -	size_t			boff,	/* starting buffer offset	*/
> -	size_t			bsize,	/* length to copy		*/
> -	void			*data,	/* data address			*/
> -	xfs_buf_rw_t		mode)	/* read/write/zero flag		*/
> +	struct xfs_buf	*bp,	/* buffer to process		*/
> +	size_t		boff,	/* starting buffer offset	*/
> +	size_t		bsize,	/* length to copy		*/
> +	void		*data,	/* data address			*/
> +	xfs_buf_rw_t	mode)	/* read/write/zero flag		*/
>  {
> -	size_t			bend;
> +	size_t		bend;
>  
>  	bend = boff + bsize;
>  	while (boff < bend) {
> @@ -1731,7 +1730,7 @@ xfs_buftarg_shrink_scan(
>  				     xfs_buftarg_isolate, &dispose);
>  
>  	while (!list_empty(&dispose)) {
> -		struct xfs_buf *bp;
> +		struct xfs_buf	*bp;
>  		bp = list_first_entry(&dispose, struct xfs_buf, b_lru);
>  		list_del_init(&bp->b_lru);
>  		xfs_buf_rele(bp);
> @@ -1767,8 +1766,8 @@ xfs_free_buftarg(
>  
>  int
>  xfs_setsize_buftarg(
> -	xfs_buftarg_t		*btp,
> -	unsigned int		sectorsize)
> +	xfs_buftarg_t	*btp,
> +	unsigned int	sectorsize)
>  {
>  	/* Set up metadata sector size info */
>  	btp->bt_meta_sectorsize = sectorsize;
> @@ -1925,7 +1924,7 @@ xfs_buf_cmp(
>  {
>  	struct xfs_buf	*ap = container_of(a, struct xfs_buf, b_list);
>  	struct xfs_buf	*bp = container_of(b, struct xfs_buf, b_list);
> -	xfs_daddr_t		diff;
> +	xfs_daddr_t	diff;
>  
>  	diff = ap->b_maps[0].bm_bn - bp->b_maps[0].bm_bn;
>  	if (diff < 0)
> @@ -2122,7 +2121,7 @@ xfs_buf_delwri_pushbuf(
>  int __init
>  xfs_buf_init(void)
>  {
> -	xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
> +	xfs_buf_zone = kmem_zone_init_flags(sizeof(struct xfs_buf), "xfs_buf",
>  						KM_ZONE_HWALIGN, NULL);
>  	if (!xfs_buf_zone)
>  		goto out;
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 5b5b4861c729..90f09e89cda2 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -143,7 +143,7 @@ struct xfs_buf_ops {
>  	xfs_failaddr_t (*verify_struct)(struct xfs_buf *bp);
>  };
>  
> -typedef struct xfs_buf {
> +struct xfs_buf {
>  	/*
>  	 * first cacheline holds all the fields needed for an uncontended cache
>  	 * hit to be fully processed. The semaphore straddles the cacheline
> @@ -214,7 +214,7 @@ typedef struct xfs_buf {
>  #ifdef XFS_BUF_LOCK_TRACKING
>  	int			b_last_holder;
>  #endif
> -} xfs_buf_t;
> +};
>  
>  /* Finding and Reading Buffers */
>  struct xfs_buf *_xfs_buf_find(struct xfs_buftarg *target,
> @@ -303,13 +303,13 @@ int xfs_buf_read_uncached(struct xfs_buftarg *target, xfs_daddr_t daddr,
>  void xfs_buf_hold(struct xfs_buf *bp);
>  
>  /* Releasing Buffers */
> -extern void xfs_buf_free(xfs_buf_t *);
> -extern void xfs_buf_rele(xfs_buf_t *);
> +extern void xfs_buf_free(struct xfs_buf *);
> +extern void xfs_buf_rele(struct xfs_buf *);
>  
>  /* Locking and Unlocking Buffers */
> -extern int xfs_buf_trylock(xfs_buf_t *);
> -extern void xfs_buf_lock(xfs_buf_t *);
> -extern void xfs_buf_unlock(xfs_buf_t *);
> +extern int xfs_buf_trylock(struct xfs_buf *);
> +extern void xfs_buf_lock(struct xfs_buf *);
> +extern void xfs_buf_unlock(struct xfs_buf *);
>  #define xfs_buf_islocked(bp) \
>  	((bp)->b_sema.count <= 0)
>  
> @@ -322,7 +322,7 @@ extern void __xfs_buf_ioerror(struct xfs_buf *bp, int error,
>  extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);
>  extern void xfs_buf_submit(struct xfs_buf *bp);
>  extern int xfs_buf_submit_wait(struct xfs_buf *bp);
> -extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
> +extern void xfs_buf_iomove(struct xfs_buf *, size_t, size_t, void *,
>  				xfs_buf_rw_t);
>  #define xfs_buf_zero(bp, off, len) \
>  	    xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO)
> @@ -362,7 +362,7 @@ static inline int xfs_buf_ispinned(struct xfs_buf *bp)
>  	return atomic_read(&bp->b_pin_count);
>  }
>  
> -static inline void xfs_buf_relse(xfs_buf_t *bp)
> +static inline void xfs_buf_relse(struct xfs_buf *bp)
>  {
>  	xfs_buf_unlock(bp);
>  	xfs_buf_rele(bp);
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 8afcfa3ed976..977a2ccc32f3 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -406,7 +406,7 @@ xfs_buf_item_unpin(
>  	int			remove)
>  {
>  	struct xfs_buf_log_item	*bip = BUF_ITEM(lip);
> -	xfs_buf_t		*bp = bip->bli_buf;
> +	struct xfs_buf		*bp = bip->bli_buf;
>  	struct xfs_ail		*ailp = lip->li_ailp;
>  	int			stale = bip->bli_flags & XFS_BLI_STALE;
>  	int			freed;
> @@ -959,7 +959,7 @@ xfs_buf_item_free(
>   */
>  void
>  xfs_buf_item_relse(
> -	xfs_buf_t	*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -986,8 +986,8 @@ xfs_buf_item_relse(
>   */
>  void
>  xfs_buf_attach_iodone(
> -	xfs_buf_t	*bp,
> -	void		(*cb)(xfs_buf_t *, xfs_log_item_t *),
> +	struct xfs_buf	*bp,
> +	void		(*cb)(struct xfs_buf *, xfs_log_item_t *),
>  	xfs_log_item_t	*lip)
>  {
>  	xfs_log_item_t	*head_lip;
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 43572f8a1b8e..a891d67bcbc9 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -221,16 +221,16 @@ xfs_qm_adjust_dqtimers(
>   */
>  STATIC void
>  xfs_qm_init_dquot_blk(
> -	xfs_trans_t	*tp,
> -	xfs_mount_t	*mp,
> -	xfs_dqid_t	id,
> -	uint		type,
> -	xfs_buf_t	*bp)
> +	xfs_trans_t		*tp,
> +	xfs_mount_t		*mp,
> +	xfs_dqid_t		id,
> +	uint			type,
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_quotainfo	*q = mp->m_quotainfo;
> -	xfs_dqblk_t	*d;
> -	xfs_dqid_t	curid;
> -	int		i;
> +	xfs_dqblk_t		*d;
> +	xfs_dqid_t		curid;
> +	int			i;
>  
>  	ASSERT(tp);
>  	ASSERT(xfs_buf_islocked(bp));
> @@ -298,13 +298,13 @@ xfs_qm_dqalloc(
>  	xfs_dquot_t	*dqp,
>  	xfs_inode_t	*quotip,
>  	xfs_fileoff_t	offset_fsb,
> -	xfs_buf_t	**O_bpp)
> +	struct xfs_buf	**O_bpp)
>  {
>  	xfs_fsblock_t	firstblock;
>  	struct xfs_defer_ops dfops;
>  	xfs_bmbt_irec_t map;
>  	int		nmaps, error;
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	xfs_trans_t	*tp = *tpp;
>  
>  	ASSERT(tp != NULL);
> @@ -409,7 +409,7 @@ xfs_qm_dqtobp(
>  	xfs_trans_t		**tpp,
>  	xfs_dquot_t		*dqp,
>  	xfs_disk_dquot_t	**O_ddpp,
> -	xfs_buf_t		**O_bpp,
> +	struct xfs_buf		**O_bpp,
>  	uint			flags)
>  {
>  	struct xfs_bmbt_irec	map;
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index 84d73835c614..37b7dcba5918 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -83,7 +83,7 @@ xfs_growfs_data_private(
>  	xfs_extlen_t		agsize;
>  	xfs_extlen_t		tmpsize;
>  	xfs_alloc_rec_t		*arec;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			bucket;
>  	int			dpct;
>  	int			error, saved_error = 0;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 663b546f2bcd..54277beb2a3d 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -749,7 +749,7 @@ xfs_ialloc(
>  	xfs_nlink_t	nlink,
>  	dev_t		rdev,
>  	prid_t		prid,
> -	xfs_buf_t	**ialloc_context,
> +	struct xfs_buf	**ialloc_context,
>  	xfs_inode_t	**ipp)
>  {
>  	struct xfs_mount *mp = tp->t_mountp;
> @@ -963,7 +963,7 @@ xfs_dir_ialloc(
>  {
>  	xfs_trans_t	*tp;
>  	xfs_inode_t	*ip;
> -	xfs_buf_t	*ialloc_context = NULL;
> +	struct xfs_buf	*ialloc_context = NULL;
>  	int		code;
>  	void		*dqinfo;
>  	uint		tflags;
> @@ -1954,8 +1954,8 @@ xfs_iunlink(
>  	xfs_mount_t	*mp = tp->t_mountp;
>  	xfs_agi_t	*agi;
>  	xfs_dinode_t	*dip;
> -	xfs_buf_t	*agibp;
> -	xfs_buf_t	*ibp;
> +	struct xfs_buf	*agibp;
> +	struct xfs_buf	*ibp;
>  	xfs_agino_t	agino;
>  	short		bucket_index;
>  	int		offset;
> @@ -2032,12 +2032,12 @@ xfs_iunlink_remove(
>  	xfs_mount_t	*mp;
>  	xfs_agi_t	*agi;
>  	xfs_dinode_t	*dip;
> -	xfs_buf_t	*agibp;
> -	xfs_buf_t	*ibp;
> +	struct xfs_buf	*agibp;
> +	struct xfs_buf	*ibp;
>  	xfs_agnumber_t	agno;
>  	xfs_agino_t	agino;
>  	xfs_agino_t	next_agino;
> -	xfs_buf_t	*last_ibp;
> +	struct xfs_buf	*last_ibp;
>  	xfs_dinode_t	*last_dip = NULL;
>  	short		bucket_index;
>  	int		offset, last_offset = 0;
> @@ -2211,7 +2211,7 @@ xfs_ifree_cluster(
>  	int			i, j;
>  	int			ioffset;
>  	xfs_daddr_t		blkno;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	xfs_inode_t		*ip;
>  	xfs_inode_log_item_t	*iip;
>  	xfs_log_item_t		*lip;
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index d58310514423..cf0bab028e19 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -346,7 +346,7 @@ xfs_bulkstat(
>  	char			__user *ubuffer, /* buffer with inode stats */
>  	int			*done)	/* 1 if there are more stats to get */
>  {
> -	xfs_buf_t		*agbp;	/* agi header buffer */
> +	struct xfs_buf		*agbp;	/* agi header buffer */
>  	xfs_agino_t		agino;	/* inode # in allocation group */
>  	xfs_agnumber_t		agno;	/* allocation group number */
>  	xfs_btree_cur_t		*cur;	/* btree cursor for ialloc btree */
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 047df85528b0..3df424328ae3 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1240,7 +1240,8 @@ xlog_space_left(
>   * happens with the buffer after the write completes.
>   */
>  static void
> -xlog_iodone(xfs_buf_t *bp)
> +xlog_iodone(
> +	struct xfs_buf		*bp)
>  {
>  	struct xlog_in_core	*iclog = bp->b_fspriv;
>  	struct xlog		*l = iclog->ic_log;
> @@ -1411,7 +1412,7 @@ xlog_alloc_log(
>  	xlog_rec_header_t	*head;
>  	xlog_in_core_t		**iclogp;
>  	xlog_in_core_t		*iclog, *prev_iclog=NULL;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			i;
>  	int			error = -ENOMEM;
>  	uint			log2_size = 0;
> @@ -1823,7 +1824,7 @@ xlog_sync(
>  	struct xlog		*log,
>  	struct xlog_in_core	*iclog)
>  {
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	int		i;
>  	uint		count;		/* byte count of bwrite */
>  	uint		count_init;	/* initial count before roundup */
> @@ -1848,10 +1849,10 @@ xlog_sync(
>  	}
>  	roundoff = count - count_init;
>  	ASSERT(roundoff >= 0);
> -	ASSERT((v2 && log->l_mp->m_sb.sb_logsunit > 1 && 
> +	ASSERT((v2 && log->l_mp->m_sb.sb_logsunit > 1 &&
>                  roundoff < log->l_mp->m_sb.sb_logsunit)
> -		|| 
> -		(log->l_mp->m_sb.sb_logsunit <= 1 && 
> +		||
> +		(log->l_mp->m_sb.sb_logsunit <= 1 &&
>  		 roundoff < BBTOB(1)));
>  
>  	/* move grant heads by roundoff in sync */
> @@ -1859,7 +1860,7 @@ xlog_sync(
>  	xlog_grant_add_space(log, &log->l_write_head.grant, roundoff);
>  
>  	/* put cycle number in every block */
> -	xlog_pack_data(log, iclog, roundoff); 
> +	xlog_pack_data(log, iclog, roundoff);
>  
>  	/* real byte length */
>  	size = iclog->ic_offset;
> @@ -2604,7 +2605,7 @@ xlog_state_clean_log(
>  			 */
>  			if (!changed &&
>  			   (be32_to_cpu(iclog->ic_header.h_num_logops) ==
> -			   		XLOG_COVER_OPS)) {
> +					XLOG_COVER_OPS)) {
>  				changed = 1;
>  			} else {
>  				/*
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 7864a298f7eb..14bf1bdcd3bc 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -108,7 +108,7 @@ xlog_verify_bp(
>   * to map to a range of nbblks basic blocks at any valid (basic
>   * block) offset within the log.
>   */
> -STATIC xfs_buf_t *
> +STATIC struct xfs_buf *
>  xlog_get_bp(
>  	struct xlog	*log,
>  	int		nbblks)
> @@ -154,7 +154,7 @@ xlog_get_bp(
>  
>  STATIC void
>  xlog_put_bp(
> -	xfs_buf_t	*bp)
> +	struct xfs_buf	*bp)
>  {
>  	xfs_buf_free(bp);
>  }
> @@ -467,7 +467,7 @@ xlog_find_verify_cycle(
>  {
>  	xfs_daddr_t	i, j;
>  	uint		cycle;
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	xfs_daddr_t	bufblks;
>  	char		*buf = NULL;
>  	int		error = 0;
> @@ -534,7 +534,7 @@ xlog_find_verify_log_record(
>  	int			extra_bblks)
>  {
>  	xfs_daddr_t		i;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	char			*offset = NULL;
>  	xlog_rec_header_t	*head = NULL;
>  	int			error = 0;
> @@ -641,7 +641,7 @@ xlog_find_head(
>  	struct xlog	*log,
>  	xfs_daddr_t	*return_head_blk)
>  {
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	char		*offset;
>  	xfs_daddr_t	new_blk, first_blk, start_blk, last_blk, head_blk;
>  	int		num_scan_bblks;
> @@ -1380,7 +1380,7 @@ xlog_find_tail(
>  {
>  	xlog_rec_header_t	*rhead;
>  	char			*offset = NULL;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			error;
>  	xfs_daddr_t		rhead_blk;
>  	xfs_lsn_t		tail_lsn;
> @@ -1529,12 +1529,12 @@ xlog_find_zeroed(
>  	struct xlog	*log,
>  	xfs_daddr_t	*blk_no)
>  {
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	char		*offset;
> -	uint	        first_cycle, last_cycle;
> +	uint		first_cycle, last_cycle;
>  	xfs_daddr_t	new_blk, last_blk, start_blk;
> -	xfs_daddr_t     num_scan_bblks;
> -	int	        error, log_bbnum = log->l_logBBsize;
> +	xfs_daddr_t	num_scan_bblks;
> +	int		error, log_bbnum = log->l_logBBsize;
>  
>  	*blk_no = 0;
>  
> @@ -1659,7 +1659,7 @@ xlog_write_log_records(
>  	int		tail_block)
>  {
>  	char		*offset;
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	int		balign, ealign;
>  	int		sectbb = log->l_sectBBsize;
>  	int		end_block = start_block + blocks;
> @@ -2802,7 +2802,7 @@ xlog_recover_buffer_pass2(
>  {
>  	xfs_buf_log_format_t	*buf_f = item->ri_buf[0].i_addr;
>  	xfs_mount_t		*mp = log->l_mp;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	int			error;
>  	uint			buf_flags;
>  	xfs_lsn_t		lsn;
> @@ -2995,7 +2995,7 @@ xlog_recover_inode_pass2(
>  {
>  	struct xfs_inode_log_format	*in_f;
>  	xfs_mount_t		*mp = log->l_mp;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	xfs_dinode_t		*dip;
>  	int			len;
>  	char			*src;
> @@ -3308,7 +3308,7 @@ xlog_recover_dquot_pass2(
>  	xfs_lsn_t			current_lsn)
>  {
>  	xfs_mount_t		*mp = log->l_mp;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	struct xfs_disk_dquot	*ddq, *recddq;
>  	xfs_failaddr_t		fa;
>  	int			error;
> @@ -5016,7 +5016,7 @@ xlog_recover_clear_agi_bucket(
>  {
>  	xfs_trans_t	*tp;
>  	xfs_agi_t	*agi;
> -	xfs_buf_t	*agibp;
> +	struct xfs_buf	*agibp;
>  	int		offset;
>  	int		error;
>  
> @@ -5123,7 +5123,7 @@ xlog_recover_process_iunlinks(
>  	xfs_mount_t	*mp;
>  	xfs_agnumber_t	agno;
>  	xfs_agi_t	*agi;
> -	xfs_buf_t	*agibp;
> +	struct xfs_buf	*agibp;
>  	xfs_agino_t	agino;
>  	int		bucket;
>  	int		error;
> @@ -5322,7 +5322,7 @@ xlog_do_recovery_pass(
>  	xfs_daddr_t		blk_no, rblk_no;
>  	xfs_daddr_t		rhead_blk;
>  	char			*offset;
> -	xfs_buf_t		*hbp, *dbp;
> +	struct xfs_buf		*hbp, *dbp;
>  	int			error = 0, h_size, h_len;
>  	int			error2 = 0;
>  	int			bblks, split_bblks;
> @@ -5670,7 +5670,7 @@ xlog_do_recover(
>  {
>  	struct xfs_mount *mp = log->l_mp;
>  	int		error;
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	xfs_sb_t	*sbp;
>  
>  	trace_xfs_log_recover(log, head_blk, tail_blk);
> @@ -5900,8 +5900,8 @@ xlog_recover_check_summary(
>  {
>  	xfs_mount_t	*mp;
>  	xfs_agf_t	*agfp;
> -	xfs_buf_t	*agfbp;
> -	xfs_buf_t	*agibp;
> +	struct xfs_buf	*agfbp;
> +	struct xfs_buf	*agibp;
>  	xfs_agnumber_t	agno;
>  	uint64_t	freeblks;
>  	uint64_t	itotal;
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index 6b9f44df7918..ccffb6358cf5 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -835,10 +835,10 @@ xfs_qm_qino_alloc(
>  
>  STATIC void
>  xfs_qm_reset_dqcounts(
> -	xfs_mount_t	*mp,
> -	xfs_buf_t	*bp,
> -	xfs_dqid_t	id,
> -	uint		type)
> +	xfs_mount_t		*mp,
> +	struct xfs_buf		*bp,
> +	xfs_dqid_t		id,
> +	uint			type)
>  {
>  	struct xfs_dqblk	*dqb;
>  	int			j;
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 488719d43ca8..5357646854cf 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -50,7 +50,7 @@ xfs_rtget_summary(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	int		log,		/* log2 of extent size */
>  	xfs_rtblock_t	bbno,		/* bitmap block number */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_suminfo_t	*sum)		/* out: summary info for this block */
>  {
> @@ -68,7 +68,7 @@ xfs_rtany_summary(
>  	int		low,		/* low log2 extent size */
>  	int		high,		/* high log2 extent size */
>  	xfs_rtblock_t	bbno,		/* bitmap block number */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	int		*stat)		/* out: any good extents here? */
>  {
> @@ -114,7 +114,7 @@ xfs_rtcopy_summary(
>  	xfs_trans_t	*tp)		/* transaction pointer */
>  {
>  	xfs_rtblock_t	bbno;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* summary buffer */
> +	struct xfs_buf	*bp;		/* summary buffer */
>  	int		error;		/* error return value */
>  	int		log;		/* summary level number (log length) */
>  	xfs_suminfo_t	sum;		/* summary data */
> @@ -154,7 +154,7 @@ xfs_rtallocate_range(
>  	xfs_trans_t	*tp,		/* transaction pointer */
>  	xfs_rtblock_t	start,		/* start block to allocate */
>  	xfs_extlen_t	len,		/* length to allocate */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb)		/* in/out: summary block number */
>  {
>  	xfs_rtblock_t	end;		/* end of the allocated extent */
> @@ -236,7 +236,7 @@ xfs_rtallocate_extent_block(
>  	xfs_extlen_t	maxlen,		/* maximum length to allocate */
>  	xfs_extlen_t	*len,		/* out: actual length allocated */
>  	xfs_rtblock_t	*nextp,		/* out: next block to try */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_extlen_t	prod,		/* extent product factor */
>  	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
> @@ -348,7 +348,7 @@ xfs_rtallocate_extent_exact(
>  	xfs_extlen_t	minlen,		/* minimum length to allocate */
>  	xfs_extlen_t	maxlen,		/* maximum length to allocate */
>  	xfs_extlen_t	*len,		/* out: actual length allocated */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_extlen_t	prod,		/* extent product factor */
>  	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
> @@ -427,7 +427,7 @@ xfs_rtallocate_extent_near(
>  	xfs_extlen_t	minlen,		/* minimum length to allocate */
>  	xfs_extlen_t	maxlen,		/* maximum length to allocate */
>  	xfs_extlen_t	*len,		/* out: actual length allocated */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_extlen_t	prod,		/* extent product factor */
>  	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
> @@ -621,7 +621,7 @@ xfs_rtallocate_extent_size(
>  	xfs_extlen_t	minlen,		/* minimum length to allocate */
>  	xfs_extlen_t	maxlen,		/* maximum length to allocate */
>  	xfs_extlen_t	*len,		/* out: actual length allocated */
> -	xfs_buf_t	**rbpp,		/* in/out: summary block buffer */
> +	struct xfs_buf	**rbpp,		/* in/out: summary block buffer */
>  	xfs_fsblock_t	*rsb,		/* in/out: summary block number */
>  	xfs_extlen_t	prod,		/* extent product factor */
>  	xfs_rtblock_t	*rtblock)	/* out: start block allocated */
> @@ -882,7 +882,7 @@ xfs_growfs_rt(
>  	xfs_growfs_rt_t	*in)		/* growfs rt input struct */
>  {
>  	xfs_rtblock_t	bmbno;		/* bitmap block number */
> -	xfs_buf_t	*bp;		/* temporary buffer */
> +	struct xfs_buf	*bp;		/* temporary buffer */
>  	int		error;		/* error return value */
>  	xfs_mount_t	*nmp;		/* new (fake) mount structure */
>  	xfs_rfsblock_t	nrblocks;	/* new number of realtime blocks */
> @@ -1101,7 +1101,7 @@ xfs_rtallocate_extent(
>  	int		error;		/* error value */
>  	xfs_rtblock_t	r;		/* result allocated block */
>  	xfs_fsblock_t	sb;		/* summary file block number */
> -	xfs_buf_t	*sumbp;		/* summary file block buffer */
> +	struct xfs_buf	*sumbp;		/* summary file block buffer */
>  
>  	ASSERT(xfs_isilocked(mp->m_rbmip, XFS_ILOCK_EXCL));
>  	ASSERT(minlen > 0 && minlen <= maxlen);
> diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
> index 3f30f846d7f2..870e14de2bcd 100644
> --- a/fs/xfs/xfs_rtalloc.h
> +++ b/fs/xfs/xfs_rtalloc.h
> @@ -122,10 +122,10 @@ int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp,
>  		       xfs_rtblock_t start, xfs_extlen_t len, int val);
>  int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp,
>  			     int log, xfs_rtblock_t bbno, int delta,
> -			     xfs_buf_t **rbpp, xfs_fsblock_t *rsb,
> +			     struct xfs_buf **rbpp, xfs_fsblock_t *rsb,
>  			     xfs_suminfo_t *sum);
>  int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log,
> -			 xfs_rtblock_t bbno, int delta, xfs_buf_t **rbpp,
> +			 xfs_rtblock_t bbno, int delta, struct xfs_buf **rbpp,
>  			 xfs_fsblock_t *rsb);
>  int xfs_rtfree_range(struct xfs_mount *mp, struct xfs_trans *tp,
>  		     xfs_rtblock_t start, xfs_extlen_t len,
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 2e9e793a8f9d..8ce22719c820 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -186,7 +186,7 @@ xfs_symlink(
>  	const char		*cur_chunk;
>  	int			byte_cnt;
>  	int			n;
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	prid_t			prid;
>  	struct xfs_dquot	*udqp = NULL;
>  	struct xfs_dquot	*gdqp = NULL;
> @@ -411,17 +411,17 @@ STATIC int
>  xfs_inactive_symlink_rmt(
>  	struct xfs_inode *ip)
>  {
> -	xfs_buf_t	*bp;
> -	int		done;
> -	int		error;
> -	xfs_fsblock_t	first_block;
> +	struct xfs_buf		*bp;
> +	int			done;
> +	int			error;
> +	xfs_fsblock_t		first_block;
>  	struct xfs_defer_ops	dfops;
> -	int		i;
> -	xfs_mount_t	*mp;
> -	xfs_bmbt_irec_t	mval[XFS_SYMLINK_MAPS];
> -	int		nmaps;
> -	int		size;
> -	xfs_trans_t	*tp;
> +	int			i;
> +	xfs_mount_t		*mp;
> +	xfs_bmbt_irec_t		mval[XFS_SYMLINK_MAPS];
> +	int			nmaps;
> +	int			size;
> +	xfs_trans_t		*tp;
>  
>  	mp = ip->i_mount;
>  	ASSERT(ip->i_df.if_flags & XFS_IFEXTENTS);
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 86f92df32c42..7d67b7274bff 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
> @@ -434,7 +434,7 @@ xfs_trans_apply_sb_deltas(
>  	xfs_trans_t	*tp)
>  {
>  	xfs_dsb_t	*sbp;
> -	xfs_buf_t	*bp;
> +	struct xfs_buf	*bp;
>  	int		whole = 0;
>  
>  	bp = xfs_trans_getsb(tp, tp->t_mountp, 0);
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 815b53d20e26..571fe499a48f 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -82,7 +82,7 @@ struct xfs_item_ops {
>  	void (*iop_unlock)(xfs_log_item_t *);
>  	xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
>  	void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
> -	void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
> +	void (*iop_error)(xfs_log_item_t *, struct xfs_buf *);
>  };
>  
>  void	xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
> diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
> index 74563cd2970c..5359c4bd95e8 100644
> --- a/fs/xfs/xfs_trans_buf.c
> +++ b/fs/xfs/xfs_trans_buf.c
> @@ -138,7 +138,7 @@ xfs_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;
>  
>  	if (!tp)
> @@ -187,13 +187,13 @@ xfs_trans_get_buf_map(
>   * buffer is a private buffer which we keep a pointer to in the
>   * mount structure.
>   */
> -xfs_buf_t *
> +struct xfs_buf *
>  xfs_trans_getsb(
>  	xfs_trans_t		*tp,
>  	struct xfs_mount	*mp,
>  	int			flags)
>  {
> -	xfs_buf_t		*bp;
> +	struct xfs_buf		*bp;
>  	struct xfs_buf_log_item	*bip;
>  
>  	/*
> @@ -355,7 +355,7 @@ xfs_trans_read_buf_map(
>  void
>  xfs_trans_brelse(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip;
>  	int			freed;
> @@ -460,7 +460,7 @@ xfs_trans_brelse(
>  void
>  xfs_trans_bhold(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -481,7 +481,7 @@ xfs_trans_bhold(
>  void
>  xfs_trans_bhold_release(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -605,7 +605,7 @@ xfs_trans_log_buf(
>  void
>  xfs_trans_binval(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  	int			i;
> @@ -660,7 +660,7 @@ xfs_trans_binval(
>  void
>  xfs_trans_inode_buf(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -684,7 +684,7 @@ xfs_trans_inode_buf(
>  void
>  xfs_trans_stale_inode_buf(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -709,7 +709,7 @@ xfs_trans_stale_inode_buf(
>  void
>  xfs_trans_inode_alloc_buf(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp)
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
>  
> @@ -802,7 +802,7 @@ xfs_trans_buf_copy_type(
>  void
>  xfs_trans_dquot_buf(
>  	xfs_trans_t		*tp,
> -	xfs_buf_t		*bp,
> +	struct xfs_buf		*bp,
>  	uint			type)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_fspriv;
> -- 
> 2.14.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Buffer's log item refactoring
  2018-01-19 21:43 ` [PATCH 0/4] Buffer's log item refactoring Darrick J. Wong
@ 2018-01-20  4:54   ` Dave Chinner
  2018-01-22 11:39     ` Carlos Maiolino
  0 siblings, 1 reply; 19+ messages in thread
From: Dave Chinner @ 2018-01-20  4:54 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Carlos Maiolino, linux-xfs

On Fri, Jan 19, 2018 at 01:43:41PM -0800, Darrick J. Wong wrote:
> On Fri, Jan 19, 2018 at 03:08:43PM +0100, Carlos Maiolino wrote:
> > Hi,
> > 
> > A few time ago Christoph suggested to use list_head API to handle buffer's
> > log_item_list.
> > 
> > This patchset aims to split the current bp->b_fspriv field into a specific field
> > to hold the xfs_buf_log_item, and another to hold the list of log items attached
> > to the buffer (3rd patch), and finally replace the singly linked list
> > implementation by the list_head infra-structure (4th patch).
> > 
> > The first two patches are just a typedef removal of xfs_buf_log_item_t and
> > xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
> > thought since we plan to get rid of the typedefs in future, this might be
> > useful.
> > 
> > I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
> > removal patches are useless, you guys call.
> 
> Typedef removal seems useful... is this series based atop current for-next?

The reason we haven't done this sort of thing in the past is that it
causes problems for people with work under development that touches
the same code. Changes like this have knock-on effects, and they are
not necessary for the changes to the li_bio_list that the last two
patches provide.

e.g. This is going to cause me pain, because I've got lots of
modifications to xfs_buf related code pending in my dev tree. A
quick glance shows a >50% hunk conflict rate across all the changes
in my tree, and that's just the kernel side.  It's hard enough to
rebase deep patch stacks correctly without having to deal with the
noise introduced by this sort of tree-wide code cleanup....

The historic process is that we remove typedefs as we go, and when
there are relatively few of them left we can do a sweep. The
xfs_buf_log_item_t is at that threshold (only about 10 uses left).

However, there's ~150 xfs_buf_t references across the kernel code
base, and there's another 175 across the xfsprogs code base of which
only 40 are in the shared libxfs code (i.e. ~300 unique xfs_buf_t
references). IMO it's still used in far to much code to do a sweep
like this without making a lot of otherwise unnecessary work for
others...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Buffer's log item refactoring
  2018-01-20  4:54   ` Dave Chinner
@ 2018-01-22 11:39     ` Carlos Maiolino
  2018-01-22 21:42       ` Darrick J. Wong
  0 siblings, 1 reply; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-22 11:39 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Darrick J. Wong, linux-xfs

On Sat, Jan 20, 2018 at 03:54:37PM +1100, Dave Chinner wrote:
> On Fri, Jan 19, 2018 at 01:43:41PM -0800, Darrick J. Wong wrote:
> > On Fri, Jan 19, 2018 at 03:08:43PM +0100, Carlos Maiolino wrote:
> > > Hi,
> > > 
> > > A few time ago Christoph suggested to use list_head API to handle buffer's
> > > log_item_list.
> > > 
> > > This patchset aims to split the current bp->b_fspriv field into a specific field
> > > to hold the xfs_buf_log_item, and another to hold the list of log items attached
> > > to the buffer (3rd patch), and finally replace the singly linked list
> > > implementation by the list_head infra-structure (4th patch).
> > > 
> > > The first two patches are just a typedef removal of xfs_buf_log_item_t and
> > > xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
> > > thought since we plan to get rid of the typedefs in future, this might be
> > > useful.
> > > 
> > > I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
> > > removal patches are useless, you guys call.
> > 
> > Typedef removal seems useful... is this series based atop current for-next?
> 

It was rebased on xfs/for-next.

> The reason we haven't done this sort of thing in the past is that it
> causes problems for people with work under development that touches
> the same code. Changes like this have knock-on effects, and they are
> not necessary for the changes to the li_bio_list that the last two
> patches provide.
> 
> e.g. This is going to cause me pain, because I've got lots of
> modifications to xfs_buf related code pending in my dev tree. A
> quick glance shows a >50% hunk conflict rate across all the changes
> in my tree, and that's just the kernel side.  It's hard enough to
> rebase deep patch stacks correctly without having to deal with the
> noise introduced by this sort of tree-wide code cleanup....
> 
> The historic process is that we remove typedefs as we go, and when
> there are relatively few of them left we can do a sweep. The
> xfs_buf_log_item_t is at that threshold (only about 10 uses left).
> 
> However, there's ~150 xfs_buf_t references across the kernel code
> base, and there's another 175 across the xfsprogs code base of which
> only 40 are in the shared libxfs code (i.e. ~300 unique xfs_buf_t
> references). IMO it's still used in far to much code to do a sweep
> like this without making a lot of otherwise unnecessary work for
> others...
>

Ok, so I'll drop the typedef patches, well, should I drop both of them or just
the xfs_buf_t? Since the xfs_buf_log_item_t has very few usages now.

Cheers

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com

-- 
Carlos

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Buffer's log item refactoring
  2018-01-22 11:39     ` Carlos Maiolino
@ 2018-01-22 21:42       ` Darrick J. Wong
  2018-01-23  8:39         ` Carlos Maiolino
  0 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-22 21:42 UTC (permalink / raw)
  To: Dave Chinner, linux-xfs

On Mon, Jan 22, 2018 at 12:39:50PM +0100, Carlos Maiolino wrote:
> On Sat, Jan 20, 2018 at 03:54:37PM +1100, Dave Chinner wrote:
> > On Fri, Jan 19, 2018 at 01:43:41PM -0800, Darrick J. Wong wrote:
> > > On Fri, Jan 19, 2018 at 03:08:43PM +0100, Carlos Maiolino wrote:
> > > > Hi,
> > > > 
> > > > A few time ago Christoph suggested to use list_head API to handle buffer's
> > > > log_item_list.
> > > > 
> > > > This patchset aims to split the current bp->b_fspriv field into a specific field
> > > > to hold the xfs_buf_log_item, and another to hold the list of log items attached
> > > > to the buffer (3rd patch), and finally replace the singly linked list
> > > > implementation by the list_head infra-structure (4th patch).
> > > > 
> > > > The first two patches are just a typedef removal of xfs_buf_log_item_t and
> > > > xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
> > > > thought since we plan to get rid of the typedefs in future, this might be
> > > > useful.
> > > > 
> > > > I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
> > > > removal patches are useless, you guys call.
> > > 
> > > Typedef removal seems useful... is this series based atop current for-next?
> > 
> 
> It was rebased on xfs/for-next.
> 
> > The reason we haven't done this sort of thing in the past is that it
> > causes problems for people with work under development that touches
> > the same code. Changes like this have knock-on effects, and they are
> > not necessary for the changes to the li_bio_list that the last two
> > patches provide.
> > 
> > e.g. This is going to cause me pain, because I've got lots of
> > modifications to xfs_buf related code pending in my dev tree. A
> > quick glance shows a >50% hunk conflict rate across all the changes
> > in my tree, and that's just the kernel side.  It's hard enough to
> > rebase deep patch stacks correctly without having to deal with the
> > noise introduced by this sort of tree-wide code cleanup....
> > 
> > The historic process is that we remove typedefs as we go, and when
> > there are relatively few of them left we can do a sweep. The
> > xfs_buf_log_item_t is at that threshold (only about 10 uses left).
> > 
> > However, there's ~150 xfs_buf_t references across the kernel code
> > base, and there's another 175 across the xfsprogs code base of which
> > only 40 are in the shared libxfs code (i.e. ~300 unique xfs_buf_t
> > references). IMO it's still used in far to much code to do a sweep
> > like this without making a lot of otherwise unnecessary work for
> > others...
> >
> 
> Ok, so I'll drop the typedef patches, well, should I drop both of them or just
> the xfs_buf_t? Since the xfs_buf_log_item_t has very few usages now.

I think it's fine to drop only the xfs_buf_t cleanup and resend with
the other cleanups.

--D

> Cheers
> 
> > Cheers,
> > 
> > Dave.
> > -- 
> > Dave Chinner
> > david@fromorbit.com
> 
> -- 
> Carlos
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] Buffer's log item refactoring
  2018-01-22 21:42       ` Darrick J. Wong
@ 2018-01-23  8:39         ` Carlos Maiolino
  0 siblings, 0 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-23  8:39 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Dave Chinner, linux-xfs

On Mon, Jan 22, 2018 at 01:42:26PM -0800, Darrick J. Wong wrote:
> On Mon, Jan 22, 2018 at 12:39:50PM +0100, Carlos Maiolino wrote:
> > On Sat, Jan 20, 2018 at 03:54:37PM +1100, Dave Chinner wrote:
> > > On Fri, Jan 19, 2018 at 01:43:41PM -0800, Darrick J. Wong wrote:
> > > > On Fri, Jan 19, 2018 at 03:08:43PM +0100, Carlos Maiolino wrote:
> > > > > Hi,
> > > > > 
> > > > > A few time ago Christoph suggested to use list_head API to handle buffer's
> > > > > log_item_list.
> > > > > 
> > > > > This patchset aims to split the current bp->b_fspriv field into a specific field
> > > > > to hold the xfs_buf_log_item, and another to hold the list of log items attached
> > > > > to the buffer (3rd patch), and finally replace the singly linked list
> > > > > implementation by the list_head infra-structure (4th patch).
> > > > > 
> > > > > The first two patches are just a typedef removal of xfs_buf_log_item_t and
> > > > > xfs_buf_t, I did while studying how all the buffer I/O mechanism works, I
> > > > > thought since we plan to get rid of the typedefs in future, this might be
> > > > > useful.
> > > > > 
> > > > > I can rebase the 3rd and 4th patch on top of current xfs tree if the typedef
> > > > > removal patches are useless, you guys call.
> > > > 
> > > > Typedef removal seems useful... is this series based atop current for-next?
> > > 
> > 
> > It was rebased on xfs/for-next.
> > 
> > > The reason we haven't done this sort of thing in the past is that it
> > > causes problems for people with work under development that touches
> > > the same code. Changes like this have knock-on effects, and they are
> > > not necessary for the changes to the li_bio_list that the last two
> > > patches provide.
> > > 
> > > e.g. This is going to cause me pain, because I've got lots of
> > > modifications to xfs_buf related code pending in my dev tree. A
> > > quick glance shows a >50% hunk conflict rate across all the changes
> > > in my tree, and that's just the kernel side.  It's hard enough to
> > > rebase deep patch stacks correctly without having to deal with the
> > > noise introduced by this sort of tree-wide code cleanup....
> > > 
> > > The historic process is that we remove typedefs as we go, and when
> > > there are relatively few of them left we can do a sweep. The
> > > xfs_buf_log_item_t is at that threshold (only about 10 uses left).
> > > 
> > > However, there's ~150 xfs_buf_t references across the kernel code
> > > base, and there's another 175 across the xfsprogs code base of which
> > > only 40 are in the shared libxfs code (i.e. ~300 unique xfs_buf_t
> > > references). IMO it's still used in far to much code to do a sweep
> > > like this without making a lot of otherwise unnecessary work for
> > > others...
> > >
> > 
> > Ok, so I'll drop the typedef patches, well, should I drop both of them or just
> > the xfs_buf_t? Since the xfs_buf_log_item_t has very few usages now.
> 
> I think it's fine to drop only the xfs_buf_t cleanup and resend with
> the other cleanups.

Thanks, I'll do that and hopefully send the V2 today yet

Cheers

-- 
Carlos

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-19 14:08 ` [PATCH 4/4] Use list_head infra-structure for buffer's log items list Carlos Maiolino
  2018-01-19 18:21   ` Darrick J. Wong
@ 2018-01-23 10:19   ` Nikolay Borisov
  2018-01-23 13:05     ` Carlos Maiolino
  1 sibling, 1 reply; 19+ messages in thread
From: Nikolay Borisov @ 2018-01-23 10:19 UTC (permalink / raw)
  To: Carlos Maiolino, linux-xfs



On 19.01.2018 16:08, Carlos Maiolino wrote:
> Now that buffer's b_fspriv has been split, just replace the current
> singly linked list of xfs_log_items, by the list_head infrastructure.
> 
> Also, remove the xfs_log_item argument from xfs_buf_resubmit_failed_buffers(),
> there is no need for this argument, once the log items can be walked
> through the list_head in the buffer.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>  fs/xfs/xfs_buf.c        |  1 +
>  fs/xfs/xfs_buf.h        |  2 +-
>  fs/xfs/xfs_buf_item.c   | 60 +++++++++++++++++++++----------------------------
>  fs/xfs/xfs_buf_item.h   |  1 -
>  fs/xfs/xfs_dquot_item.c |  2 +-
>  fs/xfs/xfs_inode.c      |  8 +++----
>  fs/xfs/xfs_inode_item.c | 41 ++++++++++-----------------------
>  fs/xfs/xfs_log.c        |  1 +
>  fs/xfs/xfs_trans.h      |  2 +-
>  9 files changed, 46 insertions(+), 72 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 07dccb05e782..47e530662db9 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -236,6 +236,7 @@ _xfs_buf_alloc(
>  	init_completion(&bp->b_iowait);
>  	INIT_LIST_HEAD(&bp->b_lru);
>  	INIT_LIST_HEAD(&bp->b_list);
> +	INIT_LIST_HEAD(&bp->b_li_list);
>  	sema_init(&bp->b_sema, 0); /* held, no waiters */
>  	spin_lock_init(&bp->b_lock);
>  	XB_SET_OWNER(bp);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 21a20d91e9e9..503221f778d3 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -177,7 +177,7 @@ struct xfs_buf {
>  	xfs_buf_iodone_t	b_iodone;	/* I/O completion function */
>  	struct completion	b_iowait;	/* queue for I/O waiters */
>  	void			*b_log_item;
> -	struct xfs_log_item	*b_li_list;
> +	struct list_head	b_li_list;	/* Log items list head */
>  	struct xfs_trans	*b_transp;
>  	struct page		**b_pages;	/* array of page pointers */
>  	struct page		*b_page_array[XB_PAGES]; /* inline pages */
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index cbb88a671b3a..33f878b51925 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -457,7 +457,7 @@ xfs_buf_item_unpin(
>  		if (bip->bli_flags & XFS_BLI_STALE_INODE) {
>  			xfs_buf_do_callbacks(bp);
>  			bp->b_log_item = NULL;
> -			bp->b_li_list = NULL;
> +			list_del_init(&bp->b_li_list);
>  			bp->b_iodone = NULL;
>  		} else {
>  			spin_lock(&ailp->xa_lock);
> @@ -955,13 +955,12 @@ xfs_buf_item_relse(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> -	struct xfs_log_item	*lip = bp->b_li_list;
>  
>  	trace_xfs_buf_item_relse(bp, _RET_IP_);
>  	ASSERT(!(bip->bli_item.li_flags & XFS_LI_IN_AIL));
>  
>  	bp->b_log_item = NULL;
> -	if (lip == NULL)
> +	if (list_empty(&bp->b_li_list))
>  		bp->b_iodone = NULL;
>  
>  	xfs_buf_rele(bp);
> @@ -982,18 +981,10 @@ xfs_buf_attach_iodone(
>  	void		(*cb)(struct xfs_buf *, xfs_log_item_t *),
>  	xfs_log_item_t	*lip)
>  {
> -	xfs_log_item_t	*head_lip;
> -
>  	ASSERT(xfs_buf_islocked(bp));
>  
>  	lip->li_cb = cb;
> -	head_lip = bp->b_li_list;
> -	if (head_lip) {
> -		lip->li_bio_list = head_lip->li_bio_list;
> -		head_lip->li_bio_list = lip;
> -	} else {
> -		bp->b_li_list = lip;
> -	}
> +	list_add_tail(&lip->li_bio_list, &bp->b_li_list);
>  
>  	ASSERT(bp->b_iodone == NULL ||
>  	       bp->b_iodone == xfs_buf_iodone_callbacks);
> @@ -1003,12 +994,12 @@ xfs_buf_attach_iodone(
>  /*
>   * We can have many callbacks on a buffer. Running the callbacks individually
>   * can cause a lot of contention on the AIL lock, so we allow for a single
> - * callback to be able to scan the remaining lip->li_bio_list for other items
> + * callback to be able to scan the remaining items in bp->b_li_list for other items
>   * of the same type and callback to be processed in the first call.
>   *
>   * As a result, the loop walking the callback list below will also modify the
>   * list. it removes the first item from the list and then runs the callback.
> - * The loop then restarts from the new head of the list. This allows the
> + * The loop then restarts from the new first item int the list. This allows the
>   * callback to scan and modify the list attached to the buffer and we don't
>   * have to care about maintaining a next item pointer.
>   */
> @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
>  		lip->li_cb(bp, lip);
>  	}
>  
> -	while ((lip = bp->b_li_list) != NULL) {
> -		bp->b_li_list = lip->li_bio_list;
> -		ASSERT(lip->li_cb != NULL);
> +	while(!list_empty(&bp->b_li_list))
> +	{

nit: Since you are iterating the list why not the canonical
list_for_each_entry_safe it will also obviate the need for
list_first_entry.

> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> +				       li_bio_list);
> +
>  		/*
> -		 * Clear the next pointer so we don't have any
> +		 * Remove the item from the list, so we don't have any
>  		 * confusion if the item is added to another buf.
>  		 * Don't touch the log item after calling its
>  		 * callback, because it could have freed itself.
>  		 */
> -		lip->li_bio_list = NULL;
> -		lip->li_cb(bp, lip);
> +		list_del_init(&lip->li_bio_list);
> +		lip->li_cb(bp,lip);
>  	}
>  }
>  
> @@ -1051,8 +1044,7 @@ STATIC void
>  xfs_buf_do_callbacks_fail(
>  	struct xfs_buf		*bp)
>  {
> -	struct xfs_log_item	*lip = bp->b_li_list;
> -	struct xfs_log_item	*next;
> +	struct xfs_log_item	*lip;
>  	struct xfs_ail		*ailp;
>  
>  	/*
> @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
>  	 * and xfs_buf_iodone_callback_error, and they have no IO error
>  	 * callbacks. Check only for items in b_li_list.
>  	 */
> -	if (lip == NULL)
> +	if (list_empty(&bp->b_li_list)) {
>  		return;
> -	else
> +	} else {
> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> +				       li_bio_list);
>  		ailp = lip->li_ailp;
> +	}
>  
>  	spin_lock(&ailp->xa_lock);
> -	for (; lip; lip = next) {
> -		next = lip->li_bio_list;
> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>  		if (lip->li_ops->iop_error)
>  			lip->li_ops->iop_error(lip, bp);
>  	}
> @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> -	struct xfs_log_item	*lip = bp->b_li_list;
> +	struct xfs_log_item	*lip;
>  	struct xfs_mount	*mp;
>  	static ulong		lasttime;
>  	static xfs_buftarg_t	*lasttarg;
> @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
>  	 * The failed buffer might not have a buf_log_item attached or the
>  	 * log_item list might be empty. Get the mp from the available xfs_log_item
>  	 */
> -	if (bip == NULL)
> +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> +					   li_bio_list)))
>  		mp = lip->li_mountp;
>  	else
>  		mp = bip->bli_item.li_mountp;
> @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
>  
>  	xfs_buf_do_callbacks(bp);
>  	bp->b_log_item = NULL;
> -	bp->b_li_list = NULL;
> +	list_del_init(&bp->b_li_list);
>  	bp->b_iodone = NULL;
>  	xfs_buf_ioend(bp);
>  }
> @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
>  bool
>  xfs_buf_resubmit_failed_buffers(
>  	struct xfs_buf		*bp,
> -	struct xfs_log_item	*lip,
>  	struct list_head	*buffer_list)
>  {
> -	struct xfs_log_item	*next;
> +	struct xfs_log_item	*lip;
>  
>  	/*
>  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
>  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
>  	 * function already have it acquired
>  	 */
> -	for (; lip; lip = next) {
> -		next = lip->li_bio_list;
> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
>  		xfs_clear_li_failed(lip);
> -	}
>  
>  	/* Add this buffer back to the delayed write list */
>  	return xfs_buf_delwri_queue(bp, buffer_list);
> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> index 0febfbbf6ba9..643f53dcfe51 100644
> --- a/fs/xfs/xfs_buf_item.h
> +++ b/fs/xfs/xfs_buf_item.h
> @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> -					struct xfs_log_item *,
>  					struct list_head *);
>  
>  extern kmem_zone_t	*xfs_buf_item_zone;
> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> index 664dea105e76..4a4539a4fad5 100644
> --- a/fs/xfs/xfs_dquot_item.c
> +++ b/fs/xfs/xfs_dquot_item.c
> @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
>  		if (!xfs_buf_trylock(bp))
>  			return XFS_ITEM_LOCKED;
>  
> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>  			rval = XFS_ITEM_FLUSHING;
>  
>  		xfs_buf_unlock(bp);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 0a4c2e48402f..8e26d3121be6 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
>  	struct xfs_buf		*bp;
>  	xfs_inode_t		*ip;
>  	xfs_inode_log_item_t	*iip;
> -	xfs_log_item_t		*lip;
> +	struct xfs_log_item	*lip;
>  	struct xfs_perag	*pag;
>  	xfs_ino_t		inum;
>  
> @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
>  		 * stale first, we will not attempt to lock them in the loop
>  		 * below as the XFS_ISTALE flag will be set.
>  		 */
> -		lip = bp->b_li_list;
> -		while (lip) {
> +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>  			if (lip->li_type == XFS_LI_INODE) {
>  				iip = (xfs_inode_log_item_t *)lip;
>  				ASSERT(iip->ili_logged == 1);
> @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
>  							&iip->ili_item.li_lsn);
>  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
>  			}
> -			lip = lip->li_bio_list;
>  		}
>  
>  
> @@ -3649,7 +3647,7 @@ xfs_iflush_int(
>  	/* generate the checksum. */
>  	xfs_dinode_calc_crc(mp, dip);
>  
> -	ASSERT(bp->b_li_list != NULL);
> +	ASSERT(!list_empty(&bp->b_li_list));
>  	ASSERT(bp->b_iodone != NULL);
>  	return 0;
>  
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 993736032b4b..ddfc2c80af5e 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -521,7 +521,7 @@ xfs_inode_item_push(
>  		if (!xfs_buf_trylock(bp))
>  			return XFS_ITEM_LOCKED;
>  
> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>  			rval = XFS_ITEM_FLUSHING;
>  
>  		xfs_buf_unlock(bp);
> @@ -712,37 +712,23 @@ xfs_iflush_done(
>  	struct xfs_log_item	*lip)
>  {
>  	struct xfs_inode_log_item *iip;
> -	struct xfs_log_item	*blip;
> -	struct xfs_log_item	*next;
> -	struct xfs_log_item	*prev;
> +	struct xfs_log_item	*blip, *n;
>  	struct xfs_ail		*ailp = lip->li_ailp;
>  	int			need_ail = 0;
> +	LIST_HEAD(tmp);
>  
>  	/*
>  	 * Scan the buffer IO completions for other inodes being completed and
>  	 * attach them to the current inode log item.
>  	 */
> -	blip = bp->b_li_list;
> -	prev = NULL;
> -	while (blip != NULL) {
> -		if (blip->li_cb != xfs_iflush_done) {
> -			prev = blip;
> -			blip = blip->li_bio_list;
> -			continue;
> -		}
>  
> -		/* remove from list */
> -		next = blip->li_bio_list;
> -		if (!prev) {
> -			bp->b_li_list = next;
> -		} else {
> -			prev->li_bio_list = next;
> -		}
> +	list_add_tail(&lip->li_bio_list, &tmp);
>  
> -		/* add to current list */
> -		blip->li_bio_list = lip->li_bio_list;
> -		lip->li_bio_list = blip;
> +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> +		if (lip->li_cb != xfs_iflush_done)
> +			continue;
>  
> +		list_move_tail(&blip->li_bio_list, &tmp);
>  		/*
>  		 * while we have the item, do the unlocked check for needing
>  		 * the AIL lock.
> @@ -751,8 +737,6 @@ xfs_iflush_done(
>  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
>  		    (blip->li_flags & XFS_LI_FAILED))
>  			need_ail++;
> -
> -		blip = next;
>  	}
>  
>  	/* make sure we capture the state of the initial inode. */
> @@ -775,7 +759,7 @@ xfs_iflush_done(
>  
>  		/* this is an opencoded batch version of xfs_trans_ail_delete */
>  		spin_lock(&ailp->xa_lock);
> -		for (blip = lip; blip; blip = blip->li_bio_list) {
> +		list_for_each_entry(blip, &tmp, li_bio_list) {
>  			if (INODE_ITEM(blip)->ili_logged &&
>  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
>  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> @@ -801,15 +785,14 @@ xfs_iflush_done(
>  	 * ili_last_fields bits now that we know that the data corresponding to
>  	 * them is safely on disk.
>  	 */
> -	for (blip = lip; blip; blip = next) {
> -		next = blip->li_bio_list;
> -		blip->li_bio_list = NULL;
> -
> +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> +		list_del_init(&blip->li_bio_list);
>  		iip = INODE_ITEM(blip);
>  		iip->ili_logged = 0;
>  		iip->ili_last_fields = 0;
>  		xfs_ifunlock(iip->ili_inode);
>  	}
> +	list_del(&tmp);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 861c84e1f674..1b5082aeb538 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1047,6 +1047,7 @@ xfs_log_item_init(
>  
>  	INIT_LIST_HEAD(&item->li_ail);
>  	INIT_LIST_HEAD(&item->li_cil);
> +	INIT_LIST_HEAD(&item->li_bio_list);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index 571fe499a48f..950cb9b4e36e 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
>  	uint				li_type;	/* item type */
>  	uint				li_flags;	/* misc flags */
>  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> +	struct list_head		li_bio_list;	/* buffer item list */
>  	void				(*li_cb)(struct xfs_buf *,
>  						 struct xfs_log_item *);
>  							/* buffer item iodone */
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-23 10:19   ` Nikolay Borisov
@ 2018-01-23 13:05     ` Carlos Maiolino
  2018-01-23 14:55       ` Nikolay Borisov
  0 siblings, 1 reply; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-23 13:05 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-xfs

> > @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
> >  		lip->li_cb(bp, lip);
> >  	}
> >  
> > -	while ((lip = bp->b_li_list) != NULL) {
> > -		bp->b_li_list = lip->li_bio_list;
> > -		ASSERT(lip->li_cb != NULL);
> > +	while(!list_empty(&bp->b_li_list))
> > +	{
> 
> nit: Since you are iterating the list why not the canonical
> list_for_each_entry_safe it will also obviate the need for
> list_first_entry.

Because the callback being called in lip->li_cb, can change the list internally,
so, even list_for_each_entry_safe here is not really safe, because the "safe"
pointer, can actually be gone before before the loop starts again
(see xfs_iflush_done()).


> 
> > +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > +				       li_bio_list);
> > +
> >  		/*
> > -		 * Clear the next pointer so we don't have any
> > +		 * Remove the item from the list, so we don't have any
> >  		 * confusion if the item is added to another buf.
> >  		 * Don't touch the log item after calling its
> >  		 * callback, because it could have freed itself.
> >  		 */
> > -		lip->li_bio_list = NULL;
> > -		lip->li_cb(bp, lip);
> > +		list_del_init(&lip->li_bio_list);
> > +		lip->li_cb(bp,lip);
> >  	}
> >  }
> >  
> > @@ -1051,8 +1044,7 @@ STATIC void
> >  xfs_buf_do_callbacks_fail(
> >  	struct xfs_buf		*bp)
> >  {
> > -	struct xfs_log_item	*lip = bp->b_li_list;
> > -	struct xfs_log_item	*next;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_ail		*ailp;
> >  
> >  	/*
> > @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
> >  	 * and xfs_buf_iodone_callback_error, and they have no IO error
> >  	 * callbacks. Check only for items in b_li_list.
> >  	 */
> > -	if (lip == NULL)
> > +	if (list_empty(&bp->b_li_list)) {
> >  		return;
> > -	else
> > +	} else {
> > +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > +				       li_bio_list);
> >  		ailp = lip->li_ailp;
> > +	}
> >  
> >  	spin_lock(&ailp->xa_lock);
> > -	for (; lip; lip = next) {
> > -		next = lip->li_bio_list;
> > +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >  		if (lip->li_ops->iop_error)
> >  			lip->li_ops->iop_error(lip, bp);
> >  	}
> > @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
> >  	struct xfs_buf		*bp)
> >  {
> >  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> > -	struct xfs_log_item	*lip = bp->b_li_list;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_mount	*mp;
> >  	static ulong		lasttime;
> >  	static xfs_buftarg_t	*lasttarg;
> > @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
> >  	 * The failed buffer might not have a buf_log_item attached or the
> >  	 * log_item list might be empty. Get the mp from the available xfs_log_item
> >  	 */
> > -	if (bip == NULL)
> > +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> > +					   li_bio_list)))
> >  		mp = lip->li_mountp;
> >  	else
> >  		mp = bip->bli_item.li_mountp;
> > @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
> >  
> >  	xfs_buf_do_callbacks(bp);
> >  	bp->b_log_item = NULL;
> > -	bp->b_li_list = NULL;
> > +	list_del_init(&bp->b_li_list);
> >  	bp->b_iodone = NULL;
> >  	xfs_buf_ioend(bp);
> >  }
> > @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
> >  bool
> >  xfs_buf_resubmit_failed_buffers(
> >  	struct xfs_buf		*bp,
> > -	struct xfs_log_item	*lip,
> >  	struct list_head	*buffer_list)
> >  {
> > -	struct xfs_log_item	*next;
> > +	struct xfs_log_item	*lip;
> >  
> >  	/*
> >  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> > @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
> >  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
> >  	 * function already have it acquired
> >  	 */
> > -	for (; lip; lip = next) {
> > -		next = lip->li_bio_list;
> > +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
> >  		xfs_clear_li_failed(lip);
> > -	}
> >  
> >  	/* Add this buffer back to the delayed write list */
> >  	return xfs_buf_delwri_queue(bp, buffer_list);
> > diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> > index 0febfbbf6ba9..643f53dcfe51 100644
> > --- a/fs/xfs/xfs_buf_item.h
> > +++ b/fs/xfs/xfs_buf_item.h
> > @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
> >  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
> >  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
> >  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> > -					struct xfs_log_item *,
> >  					struct list_head *);
> >  
> >  extern kmem_zone_t	*xfs_buf_item_zone;
> > diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> > index 664dea105e76..4a4539a4fad5 100644
> > --- a/fs/xfs/xfs_dquot_item.c
> > +++ b/fs/xfs/xfs_dquot_item.c
> > @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
> >  		if (!xfs_buf_trylock(bp))
> >  			return XFS_ITEM_LOCKED;
> >  
> > -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >  			rval = XFS_ITEM_FLUSHING;
> >  
> >  		xfs_buf_unlock(bp);
> > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > index 0a4c2e48402f..8e26d3121be6 100644
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
> >  	struct xfs_buf		*bp;
> >  	xfs_inode_t		*ip;
> >  	xfs_inode_log_item_t	*iip;
> > -	xfs_log_item_t		*lip;
> > +	struct xfs_log_item	*lip;
> >  	struct xfs_perag	*pag;
> >  	xfs_ino_t		inum;
> >  
> > @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
> >  		 * stale first, we will not attempt to lock them in the loop
> >  		 * below as the XFS_ISTALE flag will be set.
> >  		 */
> > -		lip = bp->b_li_list;
> > -		while (lip) {
> > +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >  			if (lip->li_type == XFS_LI_INODE) {
> >  				iip = (xfs_inode_log_item_t *)lip;
> >  				ASSERT(iip->ili_logged == 1);
> > @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
> >  							&iip->ili_item.li_lsn);
> >  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
> >  			}
> > -			lip = lip->li_bio_list;
> >  		}
> >  
> >  
> > @@ -3649,7 +3647,7 @@ xfs_iflush_int(
> >  	/* generate the checksum. */
> >  	xfs_dinode_calc_crc(mp, dip);
> >  
> > -	ASSERT(bp->b_li_list != NULL);
> > +	ASSERT(!list_empty(&bp->b_li_list));
> >  	ASSERT(bp->b_iodone != NULL);
> >  	return 0;
> >  
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 993736032b4b..ddfc2c80af5e 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -521,7 +521,7 @@ xfs_inode_item_push(
> >  		if (!xfs_buf_trylock(bp))
> >  			return XFS_ITEM_LOCKED;
> >  
> > -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >  			rval = XFS_ITEM_FLUSHING;
> >  
> >  		xfs_buf_unlock(bp);
> > @@ -712,37 +712,23 @@ xfs_iflush_done(
> >  	struct xfs_log_item	*lip)
> >  {
> >  	struct xfs_inode_log_item *iip;
> > -	struct xfs_log_item	*blip;
> > -	struct xfs_log_item	*next;
> > -	struct xfs_log_item	*prev;
> > +	struct xfs_log_item	*blip, *n;
> >  	struct xfs_ail		*ailp = lip->li_ailp;
> >  	int			need_ail = 0;
> > +	LIST_HEAD(tmp);
> >  
> >  	/*
> >  	 * Scan the buffer IO completions for other inodes being completed and
> >  	 * attach them to the current inode log item.
> >  	 */
> > -	blip = bp->b_li_list;
> > -	prev = NULL;
> > -	while (blip != NULL) {
> > -		if (blip->li_cb != xfs_iflush_done) {
> > -			prev = blip;
> > -			blip = blip->li_bio_list;
> > -			continue;
> > -		}
> >  
> > -		/* remove from list */
> > -		next = blip->li_bio_list;
> > -		if (!prev) {
> > -			bp->b_li_list = next;
> > -		} else {
> > -			prev->li_bio_list = next;
> > -		}
> > +	list_add_tail(&lip->li_bio_list, &tmp);
> >  
> > -		/* add to current list */
> > -		blip->li_bio_list = lip->li_bio_list;
> > -		lip->li_bio_list = blip;
> > +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> > +		if (lip->li_cb != xfs_iflush_done)
> > +			continue;
> >  
> > +		list_move_tail(&blip->li_bio_list, &tmp);
> >  		/*
> >  		 * while we have the item, do the unlocked check for needing
> >  		 * the AIL lock.
> > @@ -751,8 +737,6 @@ xfs_iflush_done(
> >  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
> >  		    (blip->li_flags & XFS_LI_FAILED))
> >  			need_ail++;
> > -
> > -		blip = next;
> >  	}
> >  
> >  	/* make sure we capture the state of the initial inode. */
> > @@ -775,7 +759,7 @@ xfs_iflush_done(
> >  
> >  		/* this is an opencoded batch version of xfs_trans_ail_delete */
> >  		spin_lock(&ailp->xa_lock);
> > -		for (blip = lip; blip; blip = blip->li_bio_list) {
> > +		list_for_each_entry(blip, &tmp, li_bio_list) {
> >  			if (INODE_ITEM(blip)->ili_logged &&
> >  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
> >  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> > @@ -801,15 +785,14 @@ xfs_iflush_done(
> >  	 * ili_last_fields bits now that we know that the data corresponding to
> >  	 * them is safely on disk.
> >  	 */
> > -	for (blip = lip; blip; blip = next) {
> > -		next = blip->li_bio_list;
> > -		blip->li_bio_list = NULL;
> > -
> > +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> > +		list_del_init(&blip->li_bio_list);
> >  		iip = INODE_ITEM(blip);
> >  		iip->ili_logged = 0;
> >  		iip->ili_last_fields = 0;
> >  		xfs_ifunlock(iip->ili_inode);
> >  	}
> > +	list_del(&tmp);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > index 861c84e1f674..1b5082aeb538 100644
> > --- a/fs/xfs/xfs_log.c
> > +++ b/fs/xfs/xfs_log.c
> > @@ -1047,6 +1047,7 @@ xfs_log_item_init(
> >  
> >  	INIT_LIST_HEAD(&item->li_ail);
> >  	INIT_LIST_HEAD(&item->li_cil);
> > +	INIT_LIST_HEAD(&item->li_bio_list);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> > index 571fe499a48f..950cb9b4e36e 100644
> > --- a/fs/xfs/xfs_trans.h
> > +++ b/fs/xfs/xfs_trans.h
> > @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
> >  	uint				li_type;	/* item type */
> >  	uint				li_flags;	/* misc flags */
> >  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> > -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> > +	struct list_head		li_bio_list;	/* buffer item list */
> >  	void				(*li_cb)(struct xfs_buf *,
> >  						 struct xfs_log_item *);
> >  							/* buffer item iodone */
> > 

-- 
Carlos

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-23 13:05     ` Carlos Maiolino
@ 2018-01-23 14:55       ` Nikolay Borisov
  2018-01-23 18:10         ` Darrick J. Wong
  0 siblings, 1 reply; 19+ messages in thread
From: Nikolay Borisov @ 2018-01-23 14:55 UTC (permalink / raw)
  To: linux-xfs



On 23.01.2018 15:05, Carlos Maiolino wrote:
>>> @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
>>>  		lip->li_cb(bp, lip);
>>>  	}
>>>  
>>> -	while ((lip = bp->b_li_list) != NULL) {
>>> -		bp->b_li_list = lip->li_bio_list;
>>> -		ASSERT(lip->li_cb != NULL);
>>> +	while(!list_empty(&bp->b_li_list))
>>> +	{
>>
>> nit: Since you are iterating the list why not the canonical
>> list_for_each_entry_safe it will also obviate the need for
>> list_first_entry.
> 
> Because the callback being called in lip->li_cb, can change the list internally,
> so, even list_for_each_entry_safe here is not really safe, because the "safe"
> pointer, can actually be gone before before the loop starts again
> (see xfs_iflush_done()).

But you invoke del_init before calling the callback, _safe suffix in
list_for_each_entry just means it's safe to call list deletion functions
without compromising list iteration.

> 
> 
>>
>>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
>>> +				       li_bio_list);
>>> +
>>>  		/*
>>> -		 * Clear the next pointer so we don't have any
>>> +		 * Remove the item from the list, so we don't have any
>>>  		 * confusion if the item is added to another buf.
>>>  		 * Don't touch the log item after calling its
>>>  		 * callback, because it could have freed itself.
>>>  		 */
>>> -		lip->li_bio_list = NULL;
>>> -		lip->li_cb(bp, lip);
>>> +		list_del_init(&lip->li_bio_list);
>>> +		lip->li_cb(bp,lip);
>>>  	}
>>>  }
>>>  
>>> @@ -1051,8 +1044,7 @@ STATIC void
>>>  xfs_buf_do_callbacks_fail(
>>>  	struct xfs_buf		*bp)
>>>  {
>>> -	struct xfs_log_item	*lip = bp->b_li_list;
>>> -	struct xfs_log_item	*next;
>>> +	struct xfs_log_item	*lip;
>>>  	struct xfs_ail		*ailp;
>>>  
>>>  	/*
>>> @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
>>>  	 * and xfs_buf_iodone_callback_error, and they have no IO error
>>>  	 * callbacks. Check only for items in b_li_list.
>>>  	 */
>>> -	if (lip == NULL)
>>> +	if (list_empty(&bp->b_li_list)) {
>>>  		return;
>>> -	else
>>> +	} else {
>>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
>>> +				       li_bio_list);
>>>  		ailp = lip->li_ailp;
>>> +	}
>>>  
>>>  	spin_lock(&ailp->xa_lock);
>>> -	for (; lip; lip = next) {
>>> -		next = lip->li_bio_list;
>>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>>>  		if (lip->li_ops->iop_error)
>>>  			lip->li_ops->iop_error(lip, bp);
>>>  	}
>>> @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
>>>  	struct xfs_buf		*bp)
>>>  {
>>>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
>>> -	struct xfs_log_item	*lip = bp->b_li_list;
>>> +	struct xfs_log_item	*lip;
>>>  	struct xfs_mount	*mp;
>>>  	static ulong		lasttime;
>>>  	static xfs_buftarg_t	*lasttarg;
>>> @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
>>>  	 * The failed buffer might not have a buf_log_item attached or the
>>>  	 * log_item list might be empty. Get the mp from the available xfs_log_item
>>>  	 */
>>> -	if (bip == NULL)
>>> +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
>>> +					   li_bio_list)))
>>>  		mp = lip->li_mountp;
>>>  	else
>>>  		mp = bip->bli_item.li_mountp;
>>> @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
>>>  
>>>  	xfs_buf_do_callbacks(bp);
>>>  	bp->b_log_item = NULL;
>>> -	bp->b_li_list = NULL;
>>> +	list_del_init(&bp->b_li_list);
>>>  	bp->b_iodone = NULL;
>>>  	xfs_buf_ioend(bp);
>>>  }
>>> @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
>>>  bool
>>>  xfs_buf_resubmit_failed_buffers(
>>>  	struct xfs_buf		*bp,
>>> -	struct xfs_log_item	*lip,
>>>  	struct list_head	*buffer_list)
>>>  {
>>> -	struct xfs_log_item	*next;
>>> +	struct xfs_log_item	*lip;
>>>  
>>>  	/*
>>>  	 * Clear XFS_LI_FAILED flag from all items before resubmit
>>> @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
>>>  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
>>>  	 * function already have it acquired
>>>  	 */
>>> -	for (; lip; lip = next) {
>>> -		next = lip->li_bio_list;
>>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
>>>  		xfs_clear_li_failed(lip);
>>> -	}
>>>  
>>>  	/* Add this buffer back to the delayed write list */
>>>  	return xfs_buf_delwri_queue(bp, buffer_list);
>>> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
>>> index 0febfbbf6ba9..643f53dcfe51 100644
>>> --- a/fs/xfs/xfs_buf_item.h
>>> +++ b/fs/xfs/xfs_buf_item.h
>>> @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
>>>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
>>>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
>>>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
>>> -					struct xfs_log_item *,
>>>  					struct list_head *);
>>>  
>>>  extern kmem_zone_t	*xfs_buf_item_zone;
>>> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
>>> index 664dea105e76..4a4539a4fad5 100644
>>> --- a/fs/xfs/xfs_dquot_item.c
>>> +++ b/fs/xfs/xfs_dquot_item.c
>>> @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
>>>  		if (!xfs_buf_trylock(bp))
>>>  			return XFS_ITEM_LOCKED;
>>>  
>>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
>>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>>>  			rval = XFS_ITEM_FLUSHING;
>>>  
>>>  		xfs_buf_unlock(bp);
>>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
>>> index 0a4c2e48402f..8e26d3121be6 100644
>>> --- a/fs/xfs/xfs_inode.c
>>> +++ b/fs/xfs/xfs_inode.c
>>> @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
>>>  	struct xfs_buf		*bp;
>>>  	xfs_inode_t		*ip;
>>>  	xfs_inode_log_item_t	*iip;
>>> -	xfs_log_item_t		*lip;
>>> +	struct xfs_log_item	*lip;
>>>  	struct xfs_perag	*pag;
>>>  	xfs_ino_t		inum;
>>>  
>>> @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
>>>  		 * stale first, we will not attempt to lock them in the loop
>>>  		 * below as the XFS_ISTALE flag will be set.
>>>  		 */
>>> -		lip = bp->b_li_list;
>>> -		while (lip) {
>>> +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
>>>  			if (lip->li_type == XFS_LI_INODE) {
>>>  				iip = (xfs_inode_log_item_t *)lip;
>>>  				ASSERT(iip->ili_logged == 1);
>>> @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
>>>  							&iip->ili_item.li_lsn);
>>>  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
>>>  			}
>>> -			lip = lip->li_bio_list;
>>>  		}
>>>  
>>>  
>>> @@ -3649,7 +3647,7 @@ xfs_iflush_int(
>>>  	/* generate the checksum. */
>>>  	xfs_dinode_calc_crc(mp, dip);
>>>  
>>> -	ASSERT(bp->b_li_list != NULL);
>>> +	ASSERT(!list_empty(&bp->b_li_list));
>>>  	ASSERT(bp->b_iodone != NULL);
>>>  	return 0;
>>>  
>>> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
>>> index 993736032b4b..ddfc2c80af5e 100644
>>> --- a/fs/xfs/xfs_inode_item.c
>>> +++ b/fs/xfs/xfs_inode_item.c
>>> @@ -521,7 +521,7 @@ xfs_inode_item_push(
>>>  		if (!xfs_buf_trylock(bp))
>>>  			return XFS_ITEM_LOCKED;
>>>  
>>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
>>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
>>>  			rval = XFS_ITEM_FLUSHING;
>>>  
>>>  		xfs_buf_unlock(bp);
>>> @@ -712,37 +712,23 @@ xfs_iflush_done(
>>>  	struct xfs_log_item	*lip)
>>>  {
>>>  	struct xfs_inode_log_item *iip;
>>> -	struct xfs_log_item	*blip;
>>> -	struct xfs_log_item	*next;
>>> -	struct xfs_log_item	*prev;
>>> +	struct xfs_log_item	*blip, *n;
>>>  	struct xfs_ail		*ailp = lip->li_ailp;
>>>  	int			need_ail = 0;
>>> +	LIST_HEAD(tmp);
>>>  
>>>  	/*
>>>  	 * Scan the buffer IO completions for other inodes being completed and
>>>  	 * attach them to the current inode log item.
>>>  	 */
>>> -	blip = bp->b_li_list;
>>> -	prev = NULL;
>>> -	while (blip != NULL) {
>>> -		if (blip->li_cb != xfs_iflush_done) {
>>> -			prev = blip;
>>> -			blip = blip->li_bio_list;
>>> -			continue;
>>> -		}
>>>  
>>> -		/* remove from list */
>>> -		next = blip->li_bio_list;
>>> -		if (!prev) {
>>> -			bp->b_li_list = next;
>>> -		} else {
>>> -			prev->li_bio_list = next;
>>> -		}
>>> +	list_add_tail(&lip->li_bio_list, &tmp);
>>>  
>>> -		/* add to current list */
>>> -		blip->li_bio_list = lip->li_bio_list;
>>> -		lip->li_bio_list = blip;
>>> +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
>>> +		if (lip->li_cb != xfs_iflush_done)
>>> +			continue;
>>>  
>>> +		list_move_tail(&blip->li_bio_list, &tmp);
>>>  		/*
>>>  		 * while we have the item, do the unlocked check for needing
>>>  		 * the AIL lock.
>>> @@ -751,8 +737,6 @@ xfs_iflush_done(
>>>  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
>>>  		    (blip->li_flags & XFS_LI_FAILED))
>>>  			need_ail++;
>>> -
>>> -		blip = next;
>>>  	}
>>>  
>>>  	/* make sure we capture the state of the initial inode. */
>>> @@ -775,7 +759,7 @@ xfs_iflush_done(
>>>  
>>>  		/* this is an opencoded batch version of xfs_trans_ail_delete */
>>>  		spin_lock(&ailp->xa_lock);
>>> -		for (blip = lip; blip; blip = blip->li_bio_list) {
>>> +		list_for_each_entry(blip, &tmp, li_bio_list) {
>>>  			if (INODE_ITEM(blip)->ili_logged &&
>>>  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
>>>  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
>>> @@ -801,15 +785,14 @@ xfs_iflush_done(
>>>  	 * ili_last_fields bits now that we know that the data corresponding to
>>>  	 * them is safely on disk.
>>>  	 */
>>> -	for (blip = lip; blip; blip = next) {
>>> -		next = blip->li_bio_list;
>>> -		blip->li_bio_list = NULL;
>>> -
>>> +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
>>> +		list_del_init(&blip->li_bio_list);
>>>  		iip = INODE_ITEM(blip);
>>>  		iip->ili_logged = 0;
>>>  		iip->ili_last_fields = 0;
>>>  		xfs_ifunlock(iip->ili_inode);
>>>  	}
>>> +	list_del(&tmp);
>>>  }
>>>  
>>>  /*
>>> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
>>> index 861c84e1f674..1b5082aeb538 100644
>>> --- a/fs/xfs/xfs_log.c
>>> +++ b/fs/xfs/xfs_log.c
>>> @@ -1047,6 +1047,7 @@ xfs_log_item_init(
>>>  
>>>  	INIT_LIST_HEAD(&item->li_ail);
>>>  	INIT_LIST_HEAD(&item->li_cil);
>>> +	INIT_LIST_HEAD(&item->li_bio_list);
>>>  }
>>>  
>>>  /*
>>> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
>>> index 571fe499a48f..950cb9b4e36e 100644
>>> --- a/fs/xfs/xfs_trans.h
>>> +++ b/fs/xfs/xfs_trans.h
>>> @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
>>>  	uint				li_type;	/* item type */
>>>  	uint				li_flags;	/* misc flags */
>>>  	struct xfs_buf			*li_buf;	/* real buffer pointer */
>>> -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
>>> +	struct list_head		li_bio_list;	/* buffer item list */
>>>  	void				(*li_cb)(struct xfs_buf *,
>>>  						 struct xfs_log_item *);
>>>  							/* buffer item iodone */
>>>
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-23 14:55       ` Nikolay Borisov
@ 2018-01-23 18:10         ` Darrick J. Wong
  2018-01-24  8:44           ` Carlos Maiolino
  0 siblings, 1 reply; 19+ messages in thread
From: Darrick J. Wong @ 2018-01-23 18:10 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-xfs

On Tue, Jan 23, 2018 at 04:55:43PM +0200, Nikolay Borisov wrote:
> 
> 
> On 23.01.2018 15:05, Carlos Maiolino wrote:
> >>> @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
> >>>  		lip->li_cb(bp, lip);
> >>>  	}
> >>>  
> >>> -	while ((lip = bp->b_li_list) != NULL) {
> >>> -		bp->b_li_list = lip->li_bio_list;
> >>> -		ASSERT(lip->li_cb != NULL);
> >>> +	while(!list_empty(&bp->b_li_list))
> >>> +	{
> >>
> >> nit: Since you are iterating the list why not the canonical
> >> list_for_each_entry_safe it will also obviate the need for
> >> list_first_entry.
> > 
> > Because the callback being called in lip->li_cb, can change the list internally,
> > so, even list_for_each_entry_safe here is not really safe, because the "safe"
> > pointer, can actually be gone before before the loop starts again
> > (see xfs_iflush_done()).
> 
> But you invoke del_init before calling the callback, _safe suffix in
> list_for_each_entry just means it's safe to call list deletion functions
> without compromising list iteration.

If I'm reading the inode item code correctly, xfs_iflush_done will skip
ahead in the list to find and process all inode items attached to the
buffer that just completed, which means that the 'n' argument to
list_for_each_entry_safe could be deleted by the time we finish the call
to li_cb, hence the while (!list_empty()) business.  The list might be
totally empty.

The comment above xfs_buf_do_callbacks states that callbacks are allowed
to play games like this (batch processing of iodone items) for the sake
of reducing ail lock contention, so while the above construction looks
funny, it seems to be the only way to accomodate this behavior.

--D

> > 
> > 
> >>
> >>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> >>> +				       li_bio_list);
> >>> +
> >>>  		/*
> >>> -		 * Clear the next pointer so we don't have any
> >>> +		 * Remove the item from the list, so we don't have any
> >>>  		 * confusion if the item is added to another buf.
> >>>  		 * Don't touch the log item after calling its
> >>>  		 * callback, because it could have freed itself.
> >>>  		 */
> >>> -		lip->li_bio_list = NULL;
> >>> -		lip->li_cb(bp, lip);
> >>> +		list_del_init(&lip->li_bio_list);
> >>> +		lip->li_cb(bp,lip);
> >>>  	}
> >>>  }
> >>>  
> >>> @@ -1051,8 +1044,7 @@ STATIC void
> >>>  xfs_buf_do_callbacks_fail(
> >>>  	struct xfs_buf		*bp)
> >>>  {
> >>> -	struct xfs_log_item	*lip = bp->b_li_list;
> >>> -	struct xfs_log_item	*next;
> >>> +	struct xfs_log_item	*lip;
> >>>  	struct xfs_ail		*ailp;
> >>>  
> >>>  	/*
> >>> @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
> >>>  	 * and xfs_buf_iodone_callback_error, and they have no IO error
> >>>  	 * callbacks. Check only for items in b_li_list.
> >>>  	 */
> >>> -	if (lip == NULL)
> >>> +	if (list_empty(&bp->b_li_list)) {
> >>>  		return;
> >>> -	else
> >>> +	} else {
> >>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> >>> +				       li_bio_list);
> >>>  		ailp = lip->li_ailp;
> >>> +	}
> >>>  
> >>>  	spin_lock(&ailp->xa_lock);
> >>> -	for (; lip; lip = next) {
> >>> -		next = lip->li_bio_list;
> >>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >>>  		if (lip->li_ops->iop_error)
> >>>  			lip->li_ops->iop_error(lip, bp);
> >>>  	}
> >>> @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
> >>>  	struct xfs_buf		*bp)
> >>>  {
> >>>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> >>> -	struct xfs_log_item	*lip = bp->b_li_list;
> >>> +	struct xfs_log_item	*lip;
> >>>  	struct xfs_mount	*mp;
> >>>  	static ulong		lasttime;
> >>>  	static xfs_buftarg_t	*lasttarg;
> >>> @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
> >>>  	 * The failed buffer might not have a buf_log_item attached or the
> >>>  	 * log_item list might be empty. Get the mp from the available xfs_log_item
> >>>  	 */
> >>> -	if (bip == NULL)
> >>> +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> >>> +					   li_bio_list)))
> >>>  		mp = lip->li_mountp;
> >>>  	else
> >>>  		mp = bip->bli_item.li_mountp;
> >>> @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
> >>>  
> >>>  	xfs_buf_do_callbacks(bp);
> >>>  	bp->b_log_item = NULL;
> >>> -	bp->b_li_list = NULL;
> >>> +	list_del_init(&bp->b_li_list);
> >>>  	bp->b_iodone = NULL;
> >>>  	xfs_buf_ioend(bp);
> >>>  }
> >>> @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
> >>>  bool
> >>>  xfs_buf_resubmit_failed_buffers(
> >>>  	struct xfs_buf		*bp,
> >>> -	struct xfs_log_item	*lip,
> >>>  	struct list_head	*buffer_list)
> >>>  {
> >>> -	struct xfs_log_item	*next;
> >>> +	struct xfs_log_item	*lip;
> >>>  
> >>>  	/*
> >>>  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> >>> @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
> >>>  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
> >>>  	 * function already have it acquired
> >>>  	 */
> >>> -	for (; lip; lip = next) {
> >>> -		next = lip->li_bio_list;
> >>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
> >>>  		xfs_clear_li_failed(lip);
> >>> -	}
> >>>  
> >>>  	/* Add this buffer back to the delayed write list */
> >>>  	return xfs_buf_delwri_queue(bp, buffer_list);
> >>> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> >>> index 0febfbbf6ba9..643f53dcfe51 100644
> >>> --- a/fs/xfs/xfs_buf_item.h
> >>> +++ b/fs/xfs/xfs_buf_item.h
> >>> @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
> >>>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
> >>>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
> >>>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> >>> -					struct xfs_log_item *,
> >>>  					struct list_head *);
> >>>  
> >>>  extern kmem_zone_t	*xfs_buf_item_zone;
> >>> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> >>> index 664dea105e76..4a4539a4fad5 100644
> >>> --- a/fs/xfs/xfs_dquot_item.c
> >>> +++ b/fs/xfs/xfs_dquot_item.c
> >>> @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
> >>>  		if (!xfs_buf_trylock(bp))
> >>>  			return XFS_ITEM_LOCKED;
> >>>  
> >>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> >>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >>>  			rval = XFS_ITEM_FLUSHING;
> >>>  
> >>>  		xfs_buf_unlock(bp);
> >>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> >>> index 0a4c2e48402f..8e26d3121be6 100644
> >>> --- a/fs/xfs/xfs_inode.c
> >>> +++ b/fs/xfs/xfs_inode.c
> >>> @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
> >>>  	struct xfs_buf		*bp;
> >>>  	xfs_inode_t		*ip;
> >>>  	xfs_inode_log_item_t	*iip;
> >>> -	xfs_log_item_t		*lip;
> >>> +	struct xfs_log_item	*lip;
> >>>  	struct xfs_perag	*pag;
> >>>  	xfs_ino_t		inum;
> >>>  
> >>> @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
> >>>  		 * stale first, we will not attempt to lock them in the loop
> >>>  		 * below as the XFS_ISTALE flag will be set.
> >>>  		 */
> >>> -		lip = bp->b_li_list;
> >>> -		while (lip) {
> >>> +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> >>>  			if (lip->li_type == XFS_LI_INODE) {
> >>>  				iip = (xfs_inode_log_item_t *)lip;
> >>>  				ASSERT(iip->ili_logged == 1);
> >>> @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
> >>>  							&iip->ili_item.li_lsn);
> >>>  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
> >>>  			}
> >>> -			lip = lip->li_bio_list;
> >>>  		}
> >>>  
> >>>  
> >>> @@ -3649,7 +3647,7 @@ xfs_iflush_int(
> >>>  	/* generate the checksum. */
> >>>  	xfs_dinode_calc_crc(mp, dip);
> >>>  
> >>> -	ASSERT(bp->b_li_list != NULL);
> >>> +	ASSERT(!list_empty(&bp->b_li_list));
> >>>  	ASSERT(bp->b_iodone != NULL);
> >>>  	return 0;
> >>>  
> >>> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> >>> index 993736032b4b..ddfc2c80af5e 100644
> >>> --- a/fs/xfs/xfs_inode_item.c
> >>> +++ b/fs/xfs/xfs_inode_item.c
> >>> @@ -521,7 +521,7 @@ xfs_inode_item_push(
> >>>  		if (!xfs_buf_trylock(bp))
> >>>  			return XFS_ITEM_LOCKED;
> >>>  
> >>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> >>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> >>>  			rval = XFS_ITEM_FLUSHING;
> >>>  
> >>>  		xfs_buf_unlock(bp);
> >>> @@ -712,37 +712,23 @@ xfs_iflush_done(
> >>>  	struct xfs_log_item	*lip)
> >>>  {
> >>>  	struct xfs_inode_log_item *iip;
> >>> -	struct xfs_log_item	*blip;
> >>> -	struct xfs_log_item	*next;
> >>> -	struct xfs_log_item	*prev;
> >>> +	struct xfs_log_item	*blip, *n;
> >>>  	struct xfs_ail		*ailp = lip->li_ailp;
> >>>  	int			need_ail = 0;
> >>> +	LIST_HEAD(tmp);
> >>>  
> >>>  	/*
> >>>  	 * Scan the buffer IO completions for other inodes being completed and
> >>>  	 * attach them to the current inode log item.
> >>>  	 */
> >>> -	blip = bp->b_li_list;
> >>> -	prev = NULL;
> >>> -	while (blip != NULL) {
> >>> -		if (blip->li_cb != xfs_iflush_done) {
> >>> -			prev = blip;
> >>> -			blip = blip->li_bio_list;
> >>> -			continue;
> >>> -		}
> >>>  
> >>> -		/* remove from list */
> >>> -		next = blip->li_bio_list;
> >>> -		if (!prev) {
> >>> -			bp->b_li_list = next;
> >>> -		} else {
> >>> -			prev->li_bio_list = next;
> >>> -		}
> >>> +	list_add_tail(&lip->li_bio_list, &tmp);
> >>>  
> >>> -		/* add to current list */
> >>> -		blip->li_bio_list = lip->li_bio_list;
> >>> -		lip->li_bio_list = blip;
> >>> +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> >>> +		if (lip->li_cb != xfs_iflush_done)
> >>> +			continue;
> >>>  
> >>> +		list_move_tail(&blip->li_bio_list, &tmp);
> >>>  		/*
> >>>  		 * while we have the item, do the unlocked check for needing
> >>>  		 * the AIL lock.
> >>> @@ -751,8 +737,6 @@ xfs_iflush_done(
> >>>  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
> >>>  		    (blip->li_flags & XFS_LI_FAILED))
> >>>  			need_ail++;
> >>> -
> >>> -		blip = next;
> >>>  	}
> >>>  
> >>>  	/* make sure we capture the state of the initial inode. */
> >>> @@ -775,7 +759,7 @@ xfs_iflush_done(
> >>>  
> >>>  		/* this is an opencoded batch version of xfs_trans_ail_delete */
> >>>  		spin_lock(&ailp->xa_lock);
> >>> -		for (blip = lip; blip; blip = blip->li_bio_list) {
> >>> +		list_for_each_entry(blip, &tmp, li_bio_list) {
> >>>  			if (INODE_ITEM(blip)->ili_logged &&
> >>>  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
> >>>  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> >>> @@ -801,15 +785,14 @@ xfs_iflush_done(
> >>>  	 * ili_last_fields bits now that we know that the data corresponding to
> >>>  	 * them is safely on disk.
> >>>  	 */
> >>> -	for (blip = lip; blip; blip = next) {
> >>> -		next = blip->li_bio_list;
> >>> -		blip->li_bio_list = NULL;
> >>> -
> >>> +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> >>> +		list_del_init(&blip->li_bio_list);
> >>>  		iip = INODE_ITEM(blip);
> >>>  		iip->ili_logged = 0;
> >>>  		iip->ili_last_fields = 0;
> >>>  		xfs_ifunlock(iip->ili_inode);
> >>>  	}
> >>> +	list_del(&tmp);
> >>>  }
> >>>  
> >>>  /*
> >>> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> >>> index 861c84e1f674..1b5082aeb538 100644
> >>> --- a/fs/xfs/xfs_log.c
> >>> +++ b/fs/xfs/xfs_log.c
> >>> @@ -1047,6 +1047,7 @@ xfs_log_item_init(
> >>>  
> >>>  	INIT_LIST_HEAD(&item->li_ail);
> >>>  	INIT_LIST_HEAD(&item->li_cil);
> >>> +	INIT_LIST_HEAD(&item->li_bio_list);
> >>>  }
> >>>  
> >>>  /*
> >>> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> >>> index 571fe499a48f..950cb9b4e36e 100644
> >>> --- a/fs/xfs/xfs_trans.h
> >>> +++ b/fs/xfs/xfs_trans.h
> >>> @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
> >>>  	uint				li_type;	/* item type */
> >>>  	uint				li_flags;	/* misc flags */
> >>>  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> >>> -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> >>> +	struct list_head		li_bio_list;	/* buffer item list */
> >>>  	void				(*li_cb)(struct xfs_buf *,
> >>>  						 struct xfs_log_item *);
> >>>  							/* buffer item iodone */
> >>>
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/4] Use list_head infra-structure for buffer's log items list
  2018-01-23 18:10         ` Darrick J. Wong
@ 2018-01-24  8:44           ` Carlos Maiolino
  0 siblings, 0 replies; 19+ messages in thread
From: Carlos Maiolino @ 2018-01-24  8:44 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Nikolay Borisov, linux-xfs

On Tue, Jan 23, 2018 at 10:10:21AM -0800, Darrick J. Wong wrote:
> On Tue, Jan 23, 2018 at 04:55:43PM +0200, Nikolay Borisov wrote:
> > 
> > 
> > On 23.01.2018 15:05, Carlos Maiolino wrote:
> > >>> @@ -1025,17 +1016,19 @@ xfs_buf_do_callbacks(
> > >>>  		lip->li_cb(bp, lip);
> > >>>  	}
> > >>>  
> > >>> -	while ((lip = bp->b_li_list) != NULL) {
> > >>> -		bp->b_li_list = lip->li_bio_list;
> > >>> -		ASSERT(lip->li_cb != NULL);
> > >>> +	while(!list_empty(&bp->b_li_list))
> > >>> +	{
> > >>
> > >> nit: Since you are iterating the list why not the canonical
> > >> list_for_each_entry_safe it will also obviate the need for
> > >> list_first_entry.
> > > 
> > > Because the callback being called in lip->li_cb, can change the list internally,
> > > so, even list_for_each_entry_safe here is not really safe, because the "safe"
> > > pointer, can actually be gone before before the loop starts again
> > > (see xfs_iflush_done()).
> > 
> > But you invoke del_init before calling the callback, _safe suffix in
> > list_for_each_entry just means it's safe to call list deletion functions
> > without compromising list iteration.
> 
> If I'm reading the inode item code correctly, xfs_iflush_done will skip
> ahead in the list to find and process all inode items attached to the
> buffer that just completed, which means that the 'n' argument to
> list_for_each_entry_safe could be deleted by the time we finish the call
> to li_cb, hence the while (!list_empty()) business.  The list might be
> totally empty.
> 

Ditto.

The xfs_buf_do_callbacks() will list_del_init() the item, but the callback can
also delete the next item on the list, the one which will be saved by
list_for_each_entry_safe(), which will result in an invalid pointer in the next
loop iteraction.

The only way we can safely remove items from the buffer's log item list in the
callback, and keep the loop safe in xfs_buf_do_callbacks, is to not trust in any
"next" pointer, and get the first item available after HEAD.

> The comment above xfs_buf_do_callbacks states that callbacks are allowed
> to play games like this (batch processing of iodone items) for the sake
> of reducing ail lock contention, so while the above construction looks
> funny, it seems to be the only way to accomodate this behavior.
> 
> --D
> 
> > > 
> > > 
> > >>
> > >>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > >>> +				       li_bio_list);
> > >>> +
> > >>>  		/*
> > >>> -		 * Clear the next pointer so we don't have any
> > >>> +		 * Remove the item from the list, so we don't have any
> > >>>  		 * confusion if the item is added to another buf.
> > >>>  		 * Don't touch the log item after calling its
> > >>>  		 * callback, because it could have freed itself.
> > >>>  		 */
> > >>> -		lip->li_bio_list = NULL;
> > >>> -		lip->li_cb(bp, lip);
> > >>> +		list_del_init(&lip->li_bio_list);
> > >>> +		lip->li_cb(bp,lip);
> > >>>  	}
> > >>>  }
> > >>>  
> > >>> @@ -1051,8 +1044,7 @@ STATIC void
> > >>>  xfs_buf_do_callbacks_fail(
> > >>>  	struct xfs_buf		*bp)
> > >>>  {
> > >>> -	struct xfs_log_item	*lip = bp->b_li_list;
> > >>> -	struct xfs_log_item	*next;
> > >>> +	struct xfs_log_item	*lip;
> > >>>  	struct xfs_ail		*ailp;
> > >>>  
> > >>>  	/*
> > >>> @@ -1060,14 +1052,16 @@ xfs_buf_do_callbacks_fail(
> > >>>  	 * and xfs_buf_iodone_callback_error, and they have no IO error
> > >>>  	 * callbacks. Check only for items in b_li_list.
> > >>>  	 */
> > >>> -	if (lip == NULL)
> > >>> +	if (list_empty(&bp->b_li_list)) {
> > >>>  		return;
> > >>> -	else
> > >>> +	} else {
> > >>> +		lip = list_first_entry(&bp->b_li_list, struct xfs_log_item,
> > >>> +				       li_bio_list);
> > >>>  		ailp = lip->li_ailp;
> > >>> +	}
> > >>>  
> > >>>  	spin_lock(&ailp->xa_lock);
> > >>> -	for (; lip; lip = next) {
> > >>> -		next = lip->li_bio_list;
> > >>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> > >>>  		if (lip->li_ops->iop_error)
> > >>>  			lip->li_ops->iop_error(lip, bp);
> > >>>  	}
> > >>> @@ -1079,7 +1073,7 @@ xfs_buf_iodone_callback_error(
> > >>>  	struct xfs_buf		*bp)
> > >>>  {
> > >>>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> > >>> -	struct xfs_log_item	*lip = bp->b_li_list;
> > >>> +	struct xfs_log_item	*lip;
> > >>>  	struct xfs_mount	*mp;
> > >>>  	static ulong		lasttime;
> > >>>  	static xfs_buftarg_t	*lasttarg;
> > >>> @@ -1089,7 +1083,8 @@ xfs_buf_iodone_callback_error(
> > >>>  	 * The failed buffer might not have a buf_log_item attached or the
> > >>>  	 * log_item list might be empty. Get the mp from the available xfs_log_item
> > >>>  	 */
> > >>> -	if (bip == NULL)
> > >>> +	if ((lip = list_first_entry_or_null(&bp->b_li_list, struct xfs_log_item,
> > >>> +					   li_bio_list)))
> > >>>  		mp = lip->li_mountp;
> > >>>  	else
> > >>>  		mp = bip->bli_item.li_mountp;
> > >>> @@ -1203,7 +1198,7 @@ xfs_buf_iodone_callbacks(
> > >>>  
> > >>>  	xfs_buf_do_callbacks(bp);
> > >>>  	bp->b_log_item = NULL;
> > >>> -	bp->b_li_list = NULL;
> > >>> +	list_del_init(&bp->b_li_list);
> > >>>  	bp->b_iodone = NULL;
> > >>>  	xfs_buf_ioend(bp);
> > >>>  }
> > >>> @@ -1248,10 +1243,9 @@ xfs_buf_iodone(
> > >>>  bool
> > >>>  xfs_buf_resubmit_failed_buffers(
> > >>>  	struct xfs_buf		*bp,
> > >>> -	struct xfs_log_item	*lip,
> > >>>  	struct list_head	*buffer_list)
> > >>>  {
> > >>> -	struct xfs_log_item	*next;
> > >>> +	struct xfs_log_item	*lip;
> > >>>  
> > >>>  	/*
> > >>>  	 * Clear XFS_LI_FAILED flag from all items before resubmit
> > >>> @@ -1259,10 +1253,8 @@ xfs_buf_resubmit_failed_buffers(
> > >>>  	 * XFS_LI_FAILED set/clear is protected by xa_lock, caller  this
> > >>>  	 * function already have it acquired
> > >>>  	 */
> > >>> -	for (; lip; lip = next) {
> > >>> -		next = lip->li_bio_list;
> > >>> +	list_for_each_entry(lip, &bp->b_li_list, li_bio_list)
> > >>>  		xfs_clear_li_failed(lip);
> > >>> -	}
> > >>>  
> > >>>  	/* Add this buffer back to the delayed write list */
> > >>>  	return xfs_buf_delwri_queue(bp, buffer_list);
> > >>> diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
> > >>> index 0febfbbf6ba9..643f53dcfe51 100644
> > >>> --- a/fs/xfs/xfs_buf_item.h
> > >>> +++ b/fs/xfs/xfs_buf_item.h
> > >>> @@ -71,7 +71,6 @@ void	xfs_buf_attach_iodone(struct xfs_buf *,
> > >>>  void	xfs_buf_iodone_callbacks(struct xfs_buf *);
> > >>>  void	xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
> > >>>  bool	xfs_buf_resubmit_failed_buffers(struct xfs_buf *,
> > >>> -					struct xfs_log_item *,
> > >>>  					struct list_head *);
> > >>>  
> > >>>  extern kmem_zone_t	*xfs_buf_item_zone;
> > >>> diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
> > >>> index 664dea105e76..4a4539a4fad5 100644
> > >>> --- a/fs/xfs/xfs_dquot_item.c
> > >>> +++ b/fs/xfs/xfs_dquot_item.c
> > >>> @@ -179,7 +179,7 @@ xfs_qm_dquot_logitem_push(
> > >>>  		if (!xfs_buf_trylock(bp))
> > >>>  			return XFS_ITEM_LOCKED;
> > >>>  
> > >>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > >>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> > >>>  			rval = XFS_ITEM_FLUSHING;
> > >>>  
> > >>>  		xfs_buf_unlock(bp);
> > >>> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> > >>> index 0a4c2e48402f..8e26d3121be6 100644
> > >>> --- a/fs/xfs/xfs_inode.c
> > >>> +++ b/fs/xfs/xfs_inode.c
> > >>> @@ -2214,7 +2214,7 @@ xfs_ifree_cluster(
> > >>>  	struct xfs_buf		*bp;
> > >>>  	xfs_inode_t		*ip;
> > >>>  	xfs_inode_log_item_t	*iip;
> > >>> -	xfs_log_item_t		*lip;
> > >>> +	struct xfs_log_item	*lip;
> > >>>  	struct xfs_perag	*pag;
> > >>>  	xfs_ino_t		inum;
> > >>>  
> > >>> @@ -2272,8 +2272,7 @@ xfs_ifree_cluster(
> > >>>  		 * stale first, we will not attempt to lock them in the loop
> > >>>  		 * below as the XFS_ISTALE flag will be set.
> > >>>  		 */
> > >>> -		lip = bp->b_li_list;
> > >>> -		while (lip) {
> > >>> +		list_for_each_entry(lip, &bp->b_li_list, li_bio_list) {
> > >>>  			if (lip->li_type == XFS_LI_INODE) {
> > >>>  				iip = (xfs_inode_log_item_t *)lip;
> > >>>  				ASSERT(iip->ili_logged == 1);
> > >>> @@ -2283,7 +2282,6 @@ xfs_ifree_cluster(
> > >>>  							&iip->ili_item.li_lsn);
> > >>>  				xfs_iflags_set(iip->ili_inode, XFS_ISTALE);
> > >>>  			}
> > >>> -			lip = lip->li_bio_list;
> > >>>  		}
> > >>>  
> > >>>  
> > >>> @@ -3649,7 +3647,7 @@ xfs_iflush_int(
> > >>>  	/* generate the checksum. */
> > >>>  	xfs_dinode_calc_crc(mp, dip);
> > >>>  
> > >>> -	ASSERT(bp->b_li_list != NULL);
> > >>> +	ASSERT(!list_empty(&bp->b_li_list));
> > >>>  	ASSERT(bp->b_iodone != NULL);
> > >>>  	return 0;
> > >>>  
> > >>> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > >>> index 993736032b4b..ddfc2c80af5e 100644
> > >>> --- a/fs/xfs/xfs_inode_item.c
> > >>> +++ b/fs/xfs/xfs_inode_item.c
> > >>> @@ -521,7 +521,7 @@ xfs_inode_item_push(
> > >>>  		if (!xfs_buf_trylock(bp))
> > >>>  			return XFS_ITEM_LOCKED;
> > >>>  
> > >>> -		if (!xfs_buf_resubmit_failed_buffers(bp, lip, buffer_list))
> > >>> +		if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list))
> > >>>  			rval = XFS_ITEM_FLUSHING;
> > >>>  
> > >>>  		xfs_buf_unlock(bp);
> > >>> @@ -712,37 +712,23 @@ xfs_iflush_done(
> > >>>  	struct xfs_log_item	*lip)
> > >>>  {
> > >>>  	struct xfs_inode_log_item *iip;
> > >>> -	struct xfs_log_item	*blip;
> > >>> -	struct xfs_log_item	*next;
> > >>> -	struct xfs_log_item	*prev;
> > >>> +	struct xfs_log_item	*blip, *n;
> > >>>  	struct xfs_ail		*ailp = lip->li_ailp;
> > >>>  	int			need_ail = 0;
> > >>> +	LIST_HEAD(tmp);
> > >>>  
> > >>>  	/*
> > >>>  	 * Scan the buffer IO completions for other inodes being completed and
> > >>>  	 * attach them to the current inode log item.
> > >>>  	 */
> > >>> -	blip = bp->b_li_list;
> > >>> -	prev = NULL;
> > >>> -	while (blip != NULL) {
> > >>> -		if (blip->li_cb != xfs_iflush_done) {
> > >>> -			prev = blip;
> > >>> -			blip = blip->li_bio_list;
> > >>> -			continue;
> > >>> -		}
> > >>>  
> > >>> -		/* remove from list */
> > >>> -		next = blip->li_bio_list;
> > >>> -		if (!prev) {
> > >>> -			bp->b_li_list = next;
> > >>> -		} else {
> > >>> -			prev->li_bio_list = next;
> > >>> -		}
> > >>> +	list_add_tail(&lip->li_bio_list, &tmp);
> > >>>  
> > >>> -		/* add to current list */
> > >>> -		blip->li_bio_list = lip->li_bio_list;
> > >>> -		lip->li_bio_list = blip;
> > >>> +	list_for_each_entry_safe(blip, n, &bp->b_li_list, li_bio_list) {
> > >>> +		if (lip->li_cb != xfs_iflush_done)
> > >>> +			continue;
> > >>>  
> > >>> +		list_move_tail(&blip->li_bio_list, &tmp);
> > >>>  		/*
> > >>>  		 * while we have the item, do the unlocked check for needing
> > >>>  		 * the AIL lock.
> > >>> @@ -751,8 +737,6 @@ xfs_iflush_done(
> > >>>  		if ((iip->ili_logged && blip->li_lsn == iip->ili_flush_lsn) ||
> > >>>  		    (blip->li_flags & XFS_LI_FAILED))
> > >>>  			need_ail++;
> > >>> -
> > >>> -		blip = next;
> > >>>  	}
> > >>>  
> > >>>  	/* make sure we capture the state of the initial inode. */
> > >>> @@ -775,7 +759,7 @@ xfs_iflush_done(
> > >>>  
> > >>>  		/* this is an opencoded batch version of xfs_trans_ail_delete */
> > >>>  		spin_lock(&ailp->xa_lock);
> > >>> -		for (blip = lip; blip; blip = blip->li_bio_list) {
> > >>> +		list_for_each_entry(blip, &tmp, li_bio_list) {
> > >>>  			if (INODE_ITEM(blip)->ili_logged &&
> > >>>  			    blip->li_lsn == INODE_ITEM(blip)->ili_flush_lsn)
> > >>>  				mlip_changed |= xfs_ail_delete_one(ailp, blip);
> > >>> @@ -801,15 +785,14 @@ xfs_iflush_done(
> > >>>  	 * ili_last_fields bits now that we know that the data corresponding to
> > >>>  	 * them is safely on disk.
> > >>>  	 */
> > >>> -	for (blip = lip; blip; blip = next) {
> > >>> -		next = blip->li_bio_list;
> > >>> -		blip->li_bio_list = NULL;
> > >>> -
> > >>> +	list_for_each_entry_safe(blip, n, &tmp, li_bio_list) {
> > >>> +		list_del_init(&blip->li_bio_list);
> > >>>  		iip = INODE_ITEM(blip);
> > >>>  		iip->ili_logged = 0;
> > >>>  		iip->ili_last_fields = 0;
> > >>>  		xfs_ifunlock(iip->ili_inode);
> > >>>  	}
> > >>> +	list_del(&tmp);
> > >>>  }
> > >>>  
> > >>>  /*
> > >>> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > >>> index 861c84e1f674..1b5082aeb538 100644
> > >>> --- a/fs/xfs/xfs_log.c
> > >>> +++ b/fs/xfs/xfs_log.c
> > >>> @@ -1047,6 +1047,7 @@ xfs_log_item_init(
> > >>>  
> > >>>  	INIT_LIST_HEAD(&item->li_ail);
> > >>>  	INIT_LIST_HEAD(&item->li_cil);
> > >>> +	INIT_LIST_HEAD(&item->li_bio_list);
> > >>>  }
> > >>>  
> > >>>  /*
> > >>> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> > >>> index 571fe499a48f..950cb9b4e36e 100644
> > >>> --- a/fs/xfs/xfs_trans.h
> > >>> +++ b/fs/xfs/xfs_trans.h
> > >>> @@ -50,7 +50,7 @@ typedef struct xfs_log_item {
> > >>>  	uint				li_type;	/* item type */
> > >>>  	uint				li_flags;	/* misc flags */
> > >>>  	struct xfs_buf			*li_buf;	/* real buffer pointer */
> > >>> -	struct xfs_log_item		*li_bio_list;	/* buffer item list */
> > >>> +	struct list_head		li_bio_list;	/* buffer item list */
> > >>>  	void				(*li_cb)(struct xfs_buf *,
> > >>>  						 struct xfs_log_item *);
> > >>>  							/* buffer item iodone */
> > >>>
> > > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Carlos

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-01-24  8:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 14:08 [PATCH 0/4] Buffer's log item refactoring Carlos Maiolino
2018-01-19 14:08 ` [PATCH 1/4] Get rid of xfs_buf_log_item_t typedef Carlos Maiolino
2018-01-20  3:33   ` Darrick J. Wong
2018-01-19 14:08 ` [PATCH 2/4] Get rid of xfs_buf_t typedef Carlos Maiolino
2018-01-20  3:35   ` Darrick J. Wong
2018-01-19 14:08 ` [PATCH 3/4] Split buffer's b_fspriv field Carlos Maiolino
2018-01-19 14:08 ` [PATCH 4/4] Use list_head infra-structure for buffer's log items list Carlos Maiolino
2018-01-19 18:21   ` Darrick J. Wong
2018-01-19 18:50     ` Carlos Maiolino
2018-01-23 10:19   ` Nikolay Borisov
2018-01-23 13:05     ` Carlos Maiolino
2018-01-23 14:55       ` Nikolay Borisov
2018-01-23 18:10         ` Darrick J. Wong
2018-01-24  8:44           ` Carlos Maiolino
2018-01-19 21:43 ` [PATCH 0/4] Buffer's log item refactoring Darrick J. Wong
2018-01-20  4:54   ` Dave Chinner
2018-01-22 11:39     ` Carlos Maiolino
2018-01-22 21:42       ` Darrick J. Wong
2018-01-23  8:39         ` Carlos Maiolino

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).