All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups
@ 2016-11-05  0:09 Darrick J. Wong
  2016-11-05  0:10 ` [PATCH 01/10] libxfs: convert ushort to unsigned short Darrick J. Wong
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Hi all,

This is a patchset that aims to fix various discrepancies between the
kernel and xfsprogs' copies of libxfs/.  They shouldn't affect the
behavior of either codebase while bringing the benefit that libxfs-apply
will run more smoothly.

The patches in this series port various libxfs changes into the kernel
codebase.  There's a patch that refactors the directory freescan code
so that xfs_repair and kernel can use the same code without the macro
wrappers and some other cleanups.

I've tested the first 7 patches successfully against the auto group,
and the ones after that have passed the quick group.

--Darrick

[1] https://github.com/djwong/linux/tree/libxfs-resync
[2] https://github.com/djwong/xfsprogs/tree/libxfs-resync

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

* [PATCH 01/10] libxfs: convert ushort to unsigned short
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:22   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 02/10] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Since xfsprogs dropped ushort in favor of unsigned short, do that
here too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_ialloc.c      |    5 +++--
 fs/xfs/libxfs/xfs_inode_buf.h   |    4 ++--
 fs/xfs/libxfs/xfs_log_format.h  |    4 ++--
 fs/xfs/libxfs/xfs_log_recover.h |    2 +-
 fs/xfs/xfs_log_recover.c        |    4 ++--
 5 files changed, 10 insertions(+), 9 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 51b4e0d..c507c1b 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2344,7 +2344,8 @@ xfs_imap(
 
 		imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno);
 		imap->im_len = XFS_FSB_TO_BB(mp, 1);
-		imap->im_boffset = (ushort)(offset << mp->m_sb.sb_inodelog);
+		imap->im_boffset = (unsigned short)(offset <<
+							mp->m_sb.sb_inodelog);
 		return 0;
 	}
 
@@ -2372,7 +2373,7 @@ xfs_imap(
 
 	imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, cluster_agbno);
 	imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster);
-	imap->im_boffset = (ushort)(offset << mp->m_sb.sb_inodelog);
+	imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
 
 	/*
 	 * If the inode number maps to a block outside the bounds
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index 3cfe12a..6848a0a 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -58,8 +58,8 @@ struct xfs_icdinode {
  */
 struct xfs_imap {
 	xfs_daddr_t	im_blkno;	/* starting BB of inode chunk */
-	ushort		im_len;		/* length in BBs of inode chunk */
-	ushort		im_boffset;	/* inode offset in block in bytes */
+	unsigned short	im_len;		/* length in BBs of inode chunk */
+	unsigned short	im_boffset;	/* inode offset in block in bytes */
 };
 
 int	xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 083cdd6..7ae571f 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -481,8 +481,8 @@ static inline uint xfs_log_dinode_size(int version)
 typedef struct xfs_buf_log_format {
 	unsigned short	blf_type;	/* buf log item type indicator */
 	unsigned short	blf_size;	/* size of this item */
-	ushort		blf_flags;	/* misc state */
-	ushort		blf_len;	/* number of blocks in this buf */
+	unsigned short	blf_flags;	/* misc state */
+	unsigned short	blf_len;	/* number of blocks in this buf */
 	__int64_t	blf_blkno;	/* starting blkno of this buf */
 	unsigned int	blf_map_size;	/* used size of data bitmap in words */
 	unsigned int	blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */
diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h
index 8e385f9..d9f65e2 100644
--- a/fs/xfs/libxfs/xfs_log_recover.h
+++ b/fs/xfs/libxfs/xfs_log_recover.h
@@ -52,7 +52,7 @@ typedef struct xlog_recover {
 	struct list_head	r_itemq;	/* q for items */
 } xlog_recover_t;
 
-#define ITEM_TYPE(i)	(*(ushort *)(i)->ri_buf[0].i_addr)
+#define ITEM_TYPE(i)	(*(unsigned short *)(i)->ri_buf[0].i_addr)
 
 /*
  * This is the number of entries in the l_buf_cancel_table used during
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9b3d7c7..cf754bc 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2025,7 +2025,7 @@ xlog_peek_buffer_cancelled(
 	struct xlog		*log,
 	xfs_daddr_t		blkno,
 	uint			len,
-	ushort			flags)
+	unsigned short			flags)
 {
 	struct list_head	*bucket;
 	struct xfs_buf_cancel	*bcp;
@@ -2065,7 +2065,7 @@ xlog_check_buffer_cancelled(
 	struct xlog		*log,
 	xfs_daddr_t		blkno,
 	uint			len,
-	ushort			flags)
+	unsigned short			flags)
 {
 	struct xfs_buf_cancel	*bcp;
 


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

* [PATCH 02/10] libxfs: synchronize dinode_verify with userspace
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
  2016-11-05  0:10 ` [PATCH 01/10] libxfs: convert ushort to unsigned short Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:23   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 03/10] libxfs: fix whitespace problems Darrick J. Wong
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

The userspace version of _dinode_verify takes a raw inode number
instead of an inode itself.  Since neither version actually needs
the inode, port the changes to the kernel.  This will also reduce
the libxfs diff noise.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_inode_buf.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 134424f..54817f8 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -383,7 +383,7 @@ xfs_log_dinode_to_disk(
 static bool
 xfs_dinode_verify(
 	struct xfs_mount	*mp,
-	struct xfs_inode	*ip,
+	xfs_ino_t		ino,
 	struct xfs_dinode	*dip)
 {
 	uint16_t		flags;
@@ -401,7 +401,7 @@ xfs_dinode_verify(
 	if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
 			      XFS_DINODE_CRC_OFF))
 		return false;
-	if (be64_to_cpu(dip->di_ino) != ip->i_ino)
+	if (be64_to_cpu(dip->di_ino) != ino)
 		return false;
 	if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
 		return false;
@@ -493,7 +493,7 @@ xfs_iread(
 		return error;
 
 	/* even unallocated inodes are verified */
-	if (!xfs_dinode_verify(mp, ip, dip)) {
+	if (!xfs_dinode_verify(mp, ip->i_ino, dip)) {
 		xfs_alert(mp, "%s: validation failed for inode %lld failed",
 				__func__, ip->i_ino);
 


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

* [PATCH 03/10] libxfs: fix whitespace problems
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
  2016-11-05  0:10 ` [PATCH 01/10] libxfs: convert ushort to unsigned short Darrick J. Wong
  2016-11-05  0:10 ` [PATCH 02/10] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:23   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration Darrick J. Wong
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Eric Sandeen

Fix some whitespace problems that trip up my libxfs-diff script.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_rtbitmap.c |    1 -
 1 file changed, 1 deletion(-)


diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index e2e1106..ea45584 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -1016,4 +1016,3 @@ xfs_rtfree_extent(
 	}
 	return 0;
 }
-


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

* [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (2 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 03/10] libxfs: fix whitespace problems Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:23   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 05/10] libxfs: clean up _dir2_data_freescan Darrick J. Wong
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Eric Sandeen

Change the xfs_attr_shortform_bytesfit declaration to have
struct xfs_inode to avoid tripping up the libxfs-diff scanner.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_attr_leaf.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
index 4f2aed0..8ef420a 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.h
+++ b/fs/xfs/libxfs/xfs_attr_leaf.h
@@ -51,7 +51,7 @@ int	xfs_attr_shortform_getvalue(struct xfs_da_args *args);
 int	xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
 int	xfs_attr_shortform_remove(struct xfs_da_args *args);
 int	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
-int	xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
+int	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
 void	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
 
 /*


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

* [PATCH 05/10] libxfs: clean up _dir2_data_freescan
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (3 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:24   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice Eric Sandeen
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Refactor the implementations of xfs_dir2_data_freescan into a
routine that takes the raw directory block parameters and
a second function that figures out the raw parameters from the
directory inode.  This enables us to use the exact same code
for both userspace and the kernel, since repair knows exactly
which directory block geometry parameters it needs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_dir2.h      |    3 +++
 fs/xfs/libxfs/xfs_dir2_data.c |   24 +++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index becc926..b55db61 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -157,6 +157,9 @@ extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
 extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
 				struct xfs_buf *bp);
 
+extern void xfs_dir2_data_freescan_int(struct xfs_da_geometry *geo,
+		const struct xfs_dir_ops *ops,
+		struct xfs_dir2_data_hdr *hdr, int *loghead);
 extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
 		struct xfs_dir2_data_hdr *hdr, int *loghead);
 extern void xfs_dir2_data_log_entry(struct xfs_da_args *args,
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 725fc78..cd75ab9 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -505,8 +505,9 @@ xfs_dir2_data_freeremove(
  * Given a data block, reconstruct its bestfree map.
  */
 void
-xfs_dir2_data_freescan(
-	struct xfs_inode	*dp,
+xfs_dir2_data_freescan_int(
+	struct xfs_da_geometry	*geo,
+	const struct xfs_dir_ops *ops,
 	struct xfs_dir2_data_hdr *hdr,
 	int			*loghead)
 {
@@ -516,7 +517,6 @@ xfs_dir2_data_freescan(
 	struct xfs_dir2_data_free *bf;
 	char			*endp;		/* end of block's data */
 	char			*p;		/* current entry pointer */
-	struct xfs_da_geometry	*geo = dp->i_mount->m_dir_geo;
 
 	ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
 	       hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
@@ -526,13 +526,13 @@ xfs_dir2_data_freescan(
 	/*
 	 * Start by clearing the table.
 	 */
-	bf = dp->d_ops->data_bestfree_p(hdr);
+	bf = ops->data_bestfree_p(hdr);
 	memset(bf, 0, sizeof(*bf) * XFS_DIR2_DATA_FD_COUNT);
 	*loghead = 1;
 	/*
 	 * Set up pointers.
 	 */
-	p = (char *)dp->d_ops->data_entry_p(hdr);
+	p = (char *)ops->data_entry_p(hdr);
 	if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
 	    hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
 		btp = xfs_dir2_block_tail_p(geo, hdr);
@@ -559,12 +559,22 @@ xfs_dir2_data_freescan(
 		else {
 			dep = (xfs_dir2_data_entry_t *)p;
 			ASSERT((char *)dep - (char *)hdr ==
-			       be16_to_cpu(*dp->d_ops->data_entry_tag_p(dep)));
-			p += dp->d_ops->data_entsize(dep->namelen);
+			       be16_to_cpu(*ops->data_entry_tag_p(dep)));
+			p += ops->data_entsize(dep->namelen);
 		}
 	}
 }
 
+void
+xfs_dir2_data_freescan(
+	struct xfs_inode	*dp,
+	struct xfs_dir2_data_hdr *hdr,
+	int			*loghead)
+{
+	return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops,
+			hdr, loghead);
+}
+
 /*
  * Initialize a data block at the given block number in the directory.
  * Give back the buffer for the created block.


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

* [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (4 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 05/10] libxfs: clean up _dir2_data_freescan Darrick J. Wong
@ 2016-11-05  0:10 ` Eric Sandeen
  2016-11-15 10:24   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails Darrick J. Wong
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Eric Sandeen @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Eryu Guan, Carlos Maiolino

>From ee3754254e8c186c99b6cdd4d59f741759d04acb Mon Sep 17 00:00:00 2001

kernel commit 5ef828c4
xfs: avoid false quotacheck after unclean shutdown

made xfs_sb_from_disk() also call xfs_sb_quota_from_disk
by default.

However, when this was merged to libxfs, existing separate
calls to libxfs_sb_quota_from_disk remained, and calling it
twice in a row on a V4 superblock leads to issues, because:

        if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
...
                sbp->sb_pquotino = sbp->sb_gquotino;
                sbp->sb_gquotino = NULLFSINO;

and after the second call, we have set both pquotino and gquotino
to NULLFSINO.

Fix this by making it safe to call twice, and also remove the extra
calls to libxfs_sb_quota_from_disk.

This is only spotted when running xfstests with "-m crc=0" because
the sb_from_disk change came about after V5 became default, and
the above behavior only exists on a V4 superblock.

Reported-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_sb.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index a70aec9..7a39240 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -338,13 +338,16 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 					XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
 	sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
 
-	if (sbp->sb_qflags & XFS_PQUOTA_ACCT)  {
+	if (sbp->sb_qflags & XFS_PQUOTA_ACCT &&
+	    sbp->sb_gquotino != NULLFSINO)  {
 		/*
 		 * In older version of superblock, on-disk superblock only
 		 * has sb_gquotino, and in-core superblock has both sb_gquotino
 		 * and sb_pquotino. But, only one of them is supported at any
 		 * point of time. So, if PQUOTA is set in disk superblock,
-		 * copy over sb_gquotino to sb_pquotino.
+		 * copy over sb_gquotino to sb_pquotino.  The NULLFSINO test
+		 * above is to make sure we don't do this twice and wipe them
+		 * both out!
 		 */
 		sbp->sb_pquotino = sbp->sb_gquotino;
 		sbp->sb_gquotino = NULLFSINO;


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

* [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (5 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice Eric Sandeen
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:24   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs Darrick J. Wong
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

If the deferred ops transaction roll fails, we need to abort the intent
items if we haven't already logged a done item for it, regardless of
whether or not the deferred ops has had a transaction committed.  Dave
found this while running generic/388.

Move the tracepoint to make it easier to track object lifetimes.

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_defer.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 613c5cf..5c2929f 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -199,9 +199,9 @@ xfs_defer_intake_work(
 	struct xfs_defer_pending	*dfp;
 
 	list_for_each_entry(dfp, &dop->dop_intake, dfp_list) {
-		trace_xfs_defer_intake_work(tp->t_mountp, dfp);
 		dfp->dfp_intent = dfp->dfp_type->create_intent(tp,
 				dfp->dfp_count);
+		trace_xfs_defer_intake_work(tp->t_mountp, dfp);
 		list_sort(tp->t_mountp, &dfp->dfp_work,
 				dfp->dfp_type->diff_items);
 		list_for_each(li, &dfp->dfp_work)
@@ -221,21 +221,14 @@ xfs_defer_trans_abort(
 	struct xfs_defer_pending	*dfp;
 
 	trace_xfs_defer_trans_abort(tp->t_mountp, dop);
-	/*
-	 * If the transaction was committed, drop the intent reference
-	 * since we're bailing out of here. The other reference is
-	 * dropped when the intent hits the AIL.  If the transaction
-	 * was not committed, the intent is freed by the intent item
-	 * unlock handler on abort.
-	 */
-	if (!dop->dop_committed)
-		return;
 
-	/* Abort intent items. */
+	/* Abort intent items that don't have a done item. */
 	list_for_each_entry(dfp, &dop->dop_pending, dfp_list) {
 		trace_xfs_defer_pending_abort(tp->t_mountp, dfp);
-		if (!dfp->dfp_done)
+		if (dfp->dfp_intent && !dfp->dfp_done) {
 			dfp->dfp_type->abort_intent(dfp->dfp_intent);
+			dfp->dfp_intent = NULL;
+		}
 	}
 
 	/* Shut down FS. */


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

* [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (6 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:25   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
  2016-11-05  0:10 ` [PATCH 10/10] xfs: check minimum block size for CRC filesystems Darrick J. Wong
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Move the declaration of _dir_ino_validate out of the private
dir2 header file into the public one, since xfsprogs did that
for the benefit of xfs_repair.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_dir2.h      |    2 ++
 fs/xfs/libxfs/xfs_dir2_priv.h |    1 -
 2 files changed, 2 insertions(+), 1 deletion(-)


diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index b55db61..0197590 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -180,6 +180,8 @@ extern struct xfs_dir2_data_free *xfs_dir2_data_freefind(
 		struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
 		struct xfs_dir2_data_unused *dup);
 
+extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
+
 extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
 extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops;
 extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
index ef9f6ea..d04547f 100644
--- a/fs/xfs/libxfs/xfs_dir2_priv.h
+++ b/fs/xfs/libxfs/xfs_dir2_priv.h
@@ -21,7 +21,6 @@
 struct dir_context;
 
 /* xfs_dir2.c */
-extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
 extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
 				xfs_dir2_db_t *dbp);
 extern int xfs_dir_cilookup_result(struct xfs_da_args *args,


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

* [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (7 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:25   ` Christoph Hellwig
  2016-11-05  0:10 ` [PATCH 10/10] xfs: check minimum block size for CRC filesystems Darrick J. Wong
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Check the return value of xfs_trans_reserve_quota_nblks for errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_bmap.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c6eb219..71dd6d7 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4902,8 +4902,11 @@ xfs_bmap_del_extent_delay(
 	 * sb counters as we might have to borrow some blocks for the
 	 * indirect block accounting.
 	 */
-	xfs_trans_reserve_quota_nblks(NULL, ip, -((long)del->br_blockcount), 0,
+	error = xfs_trans_reserve_quota_nblks(NULL, ip,
+			-((long)del->br_blockcount), 0,
 			isrt ? XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
+	if (error)
+		return error;
 	ip->i_delayed_blks -= del->br_blockcount;
 
 	if (whichfork == XFS_COW_FORK)


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

* [PATCH 10/10] xfs: check minimum block size for CRC filesystems
  2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (8 preceding siblings ...)
  2016-11-05  0:10 ` [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
@ 2016-11-05  0:10 ` Darrick J. Wong
  2016-11-15 10:25   ` Christoph Hellwig
  9 siblings, 1 reply; 21+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:10 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Check the minimum block size on v5 filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_sb.c    |    7 +++++++
 fs/xfs/libxfs/xfs_types.h |    3 +++
 2 files changed, 10 insertions(+)


diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 7a39240..49b03e6 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -262,6 +262,13 @@ xfs_mount_validate_sb(
 		return -EFSCORRUPTED;
 	}
 
+	if (xfs_sb_version_hascrc(&mp->m_sb) &&
+	    unlikely(
+	    sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE)) {
+		xfs_notice(mp, "v5 SB sanity check failed");
+		return -EFSCORRUPTED;
+	}
+
 	/*
 	 * Until this is fixed only page-sized or smaller data blocks work.
 	 */
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index 8d74870..cf044c0 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -75,11 +75,14 @@ typedef __int64_t	xfs_sfiloff_t;	/* signed block number in a file */
  * Minimum and maximum blocksize and sectorsize.
  * The blocksize upper limit is pretty much arbitrary.
  * The sectorsize upper limit is due to sizeof(sb_sectsize).
+ * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
+ * cannot be used.
  */
 #define XFS_MIN_BLOCKSIZE_LOG	9	/* i.e. 512 bytes */
 #define XFS_MAX_BLOCKSIZE_LOG	16	/* i.e. 65536 bytes */
 #define XFS_MIN_BLOCKSIZE	(1 << XFS_MIN_BLOCKSIZE_LOG)
 #define XFS_MAX_BLOCKSIZE	(1 << XFS_MAX_BLOCKSIZE_LOG)
+#define XFS_MIN_CRC_BLOCKSIZE	(1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
 #define XFS_MIN_SECTORSIZE_LOG	9	/* i.e. 512 bytes */
 #define XFS_MAX_SECTORSIZE_LOG	15	/* i.e. 32768 bytes */
 #define XFS_MIN_SECTORSIZE	(1 << XFS_MIN_SECTORSIZE_LOG)


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

* Re: [PATCH 01/10] libxfs: convert ushort to unsigned short
  2016-11-05  0:10 ` [PATCH 01/10] libxfs: convert ushort to unsigned short Darrick J. Wong
@ 2016-11-15 10:22   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:22 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:02PM -0700, Darrick J. Wong wrote:
> Since xfsprogs dropped ushort in favor of unsigned short, do that
> here too.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 02/10] libxfs: synchronize dinode_verify with userspace
  2016-11-05  0:10 ` [PATCH 02/10] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
@ 2016-11-15 10:23   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:23 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:08PM -0700, Darrick J. Wong wrote:
> The userspace version of _dinode_verify takes a raw inode number
> instead of an inode itself.  Since neither version actually needs
> the inode, port the changes to the kernel.  This will also reduce
> the libxfs diff noise.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 03/10] libxfs: fix whitespace problems
  2016-11-05  0:10 ` [PATCH 03/10] libxfs: fix whitespace problems Darrick J. Wong
@ 2016-11-15 10:23   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:23 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs, Eric Sandeen

On Fri, Nov 04, 2016 at 05:10:14PM -0700, Darrick J. Wong wrote:
> Fix some whitespace problems that trip up my libxfs-diff script.

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration
  2016-11-05  0:10 ` [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration Darrick J. Wong
@ 2016-11-15 10:23   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:23 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs, Eric Sandeen

On Fri, Nov 04, 2016 at 05:10:21PM -0700, Darrick J. Wong wrote:
> Change the xfs_attr_shortform_bytesfit declaration to have
> struct xfs_inode to avoid tripping up the libxfs-diff scanner.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 05/10] libxfs: clean up _dir2_data_freescan
  2016-11-05  0:10 ` [PATCH 05/10] libxfs: clean up _dir2_data_freescan Darrick J. Wong
@ 2016-11-15 10:24   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:24 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:27PM -0700, Darrick J. Wong wrote:
> Refactor the implementations of xfs_dir2_data_freescan into a
> routine that takes the raw directory block parameters and
> a second function that figures out the raw parameters from the
> directory inode.  This enables us to use the exact same code
> for both userspace and the kernel, since repair knows exactly
> which directory block geometry parameters it needs.

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice
  2016-11-05  0:10 ` [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice Eric Sandeen
@ 2016-11-15 10:24   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:24 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: david, darrick.wong, linux-xfs, Eryu Guan, Carlos Maiolino

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails
  2016-11-05  0:10 ` [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails Darrick J. Wong
@ 2016-11-15 10:24   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:24 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:39PM -0700, Darrick J. Wong wrote:
> If the deferred ops transaction roll fails, we need to abort the intent
> items if we haven't already logged a done item for it, regardless of
> whether or not the deferred ops has had a transaction committed.  Dave
> found this while running generic/388.
> 
> Move the tracepoint to make it easier to track object lifetimes.
> 
> Reported-by: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs
  2016-11-05  0:10 ` [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs Darrick J. Wong
@ 2016-11-15 10:25   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:25 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:45PM -0700, Darrick J. Wong wrote:
> Move the declaration of _dir_ino_validate out of the private
> dir2 header file into the public one, since xfsprogs did that
> for the benefit of xfs_repair.

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks
  2016-11-05  0:10 ` [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
@ 2016-11-15 10:25   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:25 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:51PM -0700, Darrick J. Wong wrote:
> Check the return value of xfs_trans_reserve_quota_nblks for errors.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH 10/10] xfs: check minimum block size for CRC filesystems
  2016-11-05  0:10 ` [PATCH 10/10] xfs: check minimum block size for CRC filesystems Darrick J. Wong
@ 2016-11-15 10:25   ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:25 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:10:57PM -0700, Darrick J. Wong wrote:
> Check the minimum block size on v5 filesystems.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Same comment on unlikely as for the xfsprogs version, otherwise:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

end of thread, other threads:[~2016-11-15 10:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-05  0:09 [PATCH v2 00/10] xfs: miscellaneous libxfs cleanups Darrick J. Wong
2016-11-05  0:10 ` [PATCH 01/10] libxfs: convert ushort to unsigned short Darrick J. Wong
2016-11-15 10:22   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 02/10] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
2016-11-15 10:23   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 03/10] libxfs: fix whitespace problems Darrick J. Wong
2016-11-15 10:23   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 04/10] libxfs: fix xfs_attr_shortform_bytesfit declaration Darrick J. Wong
2016-11-15 10:23   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 05/10] libxfs: clean up _dir2_data_freescan Darrick J. Wong
2016-11-15 10:24   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 06/10] xfs: don't call xfs_sb_quota_from_disk twice Eric Sandeen
2016-11-15 10:24   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 07/10] xfs: defer should abort intent items if the trans roll fails Darrick J. Wong
2016-11-15 10:24   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 08/10] xfs: move dir_ino_validate declaration per xfsprogs Darrick J. Wong
2016-11-15 10:25   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 09/10] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
2016-11-15 10:25   ` Christoph Hellwig
2016-11-05  0:10 ` [PATCH 10/10] xfs: check minimum block size for CRC filesystems Darrick J. Wong
2016-11-15 10:25   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.