All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups
@ 2016-11-05  0:07 Darrick J. Wong
  2016-11-05  0:08 ` [PATCH 01/16] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
                   ` (16 more replies)
  0 siblings, 17 replies; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:07 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 first two patches fix some problems that Coverity found with the
initial commit of userspace support for reflink.  After that are nine
patches that fix a few places where the kernel and xfsprogs' copies of
libxfs have gotten out of sync.  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 a second patch adding a script to
show the differences between any file that appears in both libxfs/
directories.

I've tested the first 11 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] 39+ messages in thread

* [PATCH 01/16] xfs_repair: fix some potential null pointer deferences
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:14   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Fix some potential NULL pointer deferences that Coverity pointed out,
and remove a trivial dead integer check.

Coverity-id: 1375789, 1375790, 1375791, 1375792
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/phase5.c |    2 +-
 repair/rmap.c   |    2 +-
 repair/slab.h   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/repair/phase5.c b/repair/phase5.c
index 3604d1d..cbda556 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1925,7 +1925,7 @@ _("Insufficient memory to construct refcount cursor."));
 	refc_rec = pop_slab_cursor(refc_cur);
 	lptr = &btree_curs->level[0];
 
-	for (i = 0; i < lptr->num_blocks; i++)  {
+	for (i = 0; i < lptr->num_blocks && refc_rec != NULL; i++)  {
 		/*
 		 * block initialization, lay in block header
 		 */
diff --git a/repair/rmap.c b/repair/rmap.c
index 45e183a..7508973 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -790,7 +790,7 @@ compute_refcounts(
 		mark_inode_rl(mp, stack_top);
 
 		/* Set nbno to the bno of the next refcount change */
-		if (n < slab_count(rmaps))
+		if (n < slab_count(rmaps) && array_cur)
 			nbno = array_cur->rm_startblock;
 		else
 			nbno = NULLAGBLOCK;
diff --git a/repair/slab.h b/repair/slab.h
index 4aa5512..a2201f1 100644
--- a/repair/slab.h
+++ b/repair/slab.h
@@ -54,7 +54,7 @@ extern void *bag_item(struct xfs_bag *, size_t);
 
 #define foreach_bag_ptr_reverse(bag, idx, ptr) \
 	for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \
-	     (idx) >= 0 && (ptr) != NULL; \
+	     (ptr) != NULL; \
 	     (idx)--, (ptr) = bag_item((bag), (idx)))
 
 #endif /* SLAB_H_ */


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

* [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
  2016-11-05  0:08 ` [PATCH 01/16] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:15   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 03/16] xfs_io: fix libxfs naming violation Darrick J. Wong
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Make the reverse mapping owner check actually validate inode numbers.

Coverity-id: 1371628
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/scan.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)


diff --git a/repair/scan.c b/repair/scan.c
index 0e13581..b9ef4dc 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -1052,8 +1052,12 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
 			}
 
 			/* Look for impossible owners. */
-			if (!(owner > 0 || (owner > XFS_RMAP_OWN_MIN &&
-					    owner <= XFS_RMAP_OWN_FS)))
+			if (!((owner > XFS_RMAP_OWN_MIN &&
+			       owner <= XFS_RMAP_OWN_FS) ||
+			      (XFS_INO_TO_AGNO(mp, owner) < mp->m_sb.sb_agcount &&
+			       XFS_AGINO_TO_AGBNO(mp,
+					XFS_INO_TO_AGINO(mp, owner)) <
+					mp->m_sb.sb_agblocks)))
 				do_warn(
 	_("invalid owner in rmap btree record %d (%"PRId64" %u) block %u/%u\n"),
 						i, owner, len, agno, bno);


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

* [PATCH 03/16] xfs_io: fix libxfs naming violation
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
  2016-11-05  0:08 ` [PATCH 01/16] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
  2016-11-05  0:08 ` [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:15   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers Darrick J. Wong
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

All the calls to libxfs code should start with 'libxfs'
per libxfs_api_defs.h.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/db/io.c b/db/io.c
index 8610f4d..f398195 100644
--- a/db/io.c
+++ b/db/io.c
@@ -504,7 +504,7 @@ write_cur(void)
 	/* If we didn't write the crc automatically, re-check inode validity */
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    skip_crc && iocur_top->ino_buf) {
-		iocur_top->ino_crc_ok = xfs_verify_cksum(iocur_top->data,
+		iocur_top->ino_crc_ok = libxfs_verify_cksum(iocur_top->data,
 						mp->m_sb.sb_inodesize,
 						XFS_DINODE_CRC_OFF);
 	}


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

* [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (2 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 03/16] xfs_io: fix libxfs naming violation Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:16   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

xfs_btree_sblock_v5hdr_verify already checks _hascrc, so we can
remove it from the verifier functions.  For whatever reason this
change made it into the kernel but not xfsprogs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_alloc_btree.c  |    4 ----
 libxfs/xfs_ialloc_btree.c |    2 --
 2 files changed, 6 deletions(-)


diff --git a/libxfs/xfs_alloc_btree.c b/libxfs/xfs_alloc_btree.c
index f993b87..ff4bae4 100644
--- a/libxfs/xfs_alloc_btree.c
+++ b/libxfs/xfs_alloc_btree.c
@@ -278,8 +278,6 @@ xfs_allocbt_verify(
 	level = be16_to_cpu(block->bb_level);
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
-		if (!xfs_sb_version_hascrc(&mp->m_sb))
-			return false;
 		if (!xfs_btree_sblock_v5hdr_verify(bp))
 			return false;
 		/* fall through */
@@ -291,8 +289,6 @@ xfs_allocbt_verify(
 			return false;
 		break;
 	case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
-		if (!xfs_sb_version_hascrc(&mp->m_sb))
-			return false;
 		if (!xfs_btree_sblock_v5hdr_verify(bp))
 			return false;
 		/* fall through */
diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c
index 8ccabcc..7bf6040 100644
--- a/libxfs/xfs_ialloc_btree.c
+++ b/libxfs/xfs_ialloc_btree.c
@@ -225,8 +225,6 @@ xfs_inobt_verify(
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_IBT_CRC_MAGIC):
 	case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
-		if (!xfs_sb_version_hascrc(&mp->m_sb))
-			return false;
 		if (!xfs_btree_sblock_v5hdr_verify(bp))
 			return false;
 		/* fall through */


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

* [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (3 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers Darrick J. Wong
@ 2016-11-05  0:08 ` Eric Sandeen
  2016-11-15 10:16   ` Christoph Hellwig
  2016-11-22 18:21   ` [PATCH v2 " Darrick J. Wong
  2016-11-05  0:08 ` [PATCH 06/16] libxfs: refactor btree crc verifier Darrick J. Wong
                   ` (11 subsequent siblings)
  16 siblings, 2 replies; 39+ messages in thread
From: Eric Sandeen @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Dave Chinner

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

It's entirely possible for userspace to ask for an xattr which
does not exist.

Normally, there is no problem whatsoever when we ask for such
a thing, but when we look at an obfuscated metadump image
on a debug kernel with selinux, we trip over this ASSERT in
xfs_da3_path_shift():

        *result = -ENOENT;      /* we're out of our tree */
        ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);

It (more or less) only shows up in the above scenario, because
xfs_metadump obfuscates attr names, but chooses names which
keep the same hash value - and xfs_da3_node_lookup_int does:

        if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
            (blk->hashval == args->hashval)) {
                error = xfs_da3_path_shift(state, &state->path, 1, 1,
                                                 &retval);

IOWS, we only get down to the xfs_da3_path_shift() ASSERT
if we are looking for an xattr which doesn't exist, but we
find xattrs on disk which have the same hash, and so might be
a hash collision, so we try the path shift.  When *that*
fails to find what we're looking for, we hit the assert about
XFS_DA_OP_OKNOENT.

Simply setting XFS_DA_OP_OKNOENT in xfs_attr_get solves this
rather corner-case problem with no ill side effects.  It's
fine for an attr name lookup to fail.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_attr.c |    2 ++
 1 file changed, 2 insertions(+)


diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index c7f0afa..60513f9 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -135,6 +135,8 @@ xfs_attr_get(
 
 	args.value = value;
 	args.valuelen = *valuelenp;
+	/* Entirely possible to look up a name which doesn't exist */
+	args.op_flags = XFS_DA_OP_OKNOENT;
 
 	lock_mode = xfs_ilock_attr_map_shared(ip);
 	if (!xfs_inode_hasattr(ip))


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

* [PATCH 06/16] libxfs: refactor btree crc verifier
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (4 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:17   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 07/16] libxfs: fix whitespace to match the kernel Darrick J. Wong
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

In a65d8d293b ("libxfs: validate metadata LSNs against log on v5
superblocks") the hascrc check was modified to use the helper mp
variable in the kernel.  This was left out of the xfsprogs patch, so
change it here too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_btree.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 1d41265..3dea6bd 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -244,7 +244,7 @@ xfs_btree_lblock_verify_crc(
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb)) {
+	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn)))
 			return false;
 		return xfs_buf_verify_cksum(bp, XFS_BTREE_LBLOCK_CRC_OFF);
@@ -282,7 +282,7 @@ xfs_btree_sblock_verify_crc(
 	struct xfs_btree_block  *block = XFS_BUF_TO_BLOCK(bp);
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&bp->b_target->bt_mount->m_sb)) {
+	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn)))
 			return false;
 		return xfs_buf_verify_cksum(bp, XFS_BTREE_SBLOCK_CRC_OFF);


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

* [PATCH 07/16] libxfs: fix whitespace to match the kernel
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (5 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 06/16] libxfs: refactor btree crc verifier Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:17   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid Darrick J. Wong
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Fix some minor whitespace errors so that my automated libxfs diff
scanning will stop reporting this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_dir2_node.c  |    2 ++
 libxfs/xfs_format.h     |    1 -
 libxfs/xfs_inode_buf.c  |    1 -
 libxfs/xfs_inode_fork.c |    1 +
 4 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c
index df599f9..b75b432 100644
--- a/libxfs/xfs_dir2_node.c
+++ b/libxfs/xfs_dir2_node.c
@@ -2146,12 +2146,14 @@ xfs_dir2_node_replace(
 	state = xfs_da_state_alloc();
 	state->args = args;
 	state->mp = args->dp->i_mount;
+
 	/*
 	 * We have to save new inode number and ftype since
 	 * xfs_da3_node_lookup_int() is going to overwrite them
 	 */
 	inum = args->inumber;
 	ftype = args->filetype;
+
 	/*
 	 * Lookup the entry to change in the btree.
 	 */
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index 172fdfb..8628bab 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -473,7 +473,6 @@ xfs_sb_has_ro_compat_feature(
 #define XFS_SB_FEAT_INCOMPAT_FTYPE	(1 << 0)	/* filetype in dirent */
 #define XFS_SB_FEAT_INCOMPAT_SPINODES	(1 << 1)	/* sparse inode chunks */
 #define XFS_SB_FEAT_INCOMPAT_META_UUID	(1 << 2)	/* metadata UUID */
-
 #define XFS_SB_FEAT_INCOMPAT_ALL \
 		(XFS_SB_FEAT_INCOMPAT_FTYPE|	\
 		 XFS_SB_FEAT_INCOMPAT_SPINODES|	\
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 4796a59..8732359 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -537,7 +537,6 @@ xfs_iread(
 	}
 
 	ASSERT(ip->i_d.di_version >= 2);
-
 	ip->i_delayed_blks = 0;
 
 	/*
diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
index 8212f77..2799e2d 100644
--- a/libxfs/xfs_inode_fork.c
+++ b/libxfs/xfs_inode_fork.c
@@ -29,6 +29,7 @@
 #include "xfs_attr_sf.h"
 #include "xfs_da_format.h"
 
+
 kmem_zone_t *xfs_ifork_zone;
 
 STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int);


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

* [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (6 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 07/16] libxfs: fix whitespace to match the kernel Darrick J. Wong
@ 2016-11-05  0:08 ` Darrick J. Wong
  2016-11-15 10:17   ` Christoph Hellwig
  2016-11-05  0:08 ` [PATCH 09/16] xfs: fix btree cursor error cleanups Brian Foster
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

The kernel's version of this function returns bool, so do so here too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_format.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index 8628bab..e14f964 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -536,7 +536,7 @@ static inline bool xfs_sb_version_hassparseinodes(struct xfs_sb *sbp)
  * user-visible UUID to be changed on V5 filesystems which have a
  * filesystem UUID stamped into every piece of metadata.
  */
-static inline int xfs_sb_version_hasmetauuid(xfs_sb_t *sbp)
+static inline bool xfs_sb_version_hasmetauuid(struct xfs_sb *sbp)
 {
 	return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) &&
 		(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID);


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

* [PATCH 09/16] xfs: fix btree cursor error cleanups
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (7 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid Darrick J. Wong
@ 2016-11-05  0:08 ` Brian Foster
  2016-11-15 10:18   ` Christoph Hellwig
  2016-11-22 18:23   ` [PATCH v2 " Darrick J. Wong
  2016-11-05  0:09 ` [PATCH 10/16] libxfs: clean up _dir2_data_freescan Darrick J. Wong
                   ` (7 subsequent siblings)
  16 siblings, 2 replies; 39+ messages in thread
From: Brian Foster @ 2016-11-05  0:08 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Christoph Hellwig

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

The btree cursor cleanup function takes an error parameter that
affects how buffers are released from the cursor. All buffers are
released in the event of error. Several callers do not specify the
XFS_BTREE_ERROR flag in the event of error, however. This can cause
buffers to hang around locked or with an elevated hold count and
thus lead to umount hangs in the event of errors.

Fix up the xfs_btree_del_cursor() callers to pass XFS_BTREE_ERROR if
the cursor is being torn down due to error.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_ialloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index f0f243e..5c88b0b 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -2232,7 +2232,7 @@ xfs_imap_lookup(
 	}
 
 	xfs_trans_brelse(tp, agbp);
-	xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
+	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
 	if (error)
 		return error;
 


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

* [PATCH 10/16] libxfs: clean up _dir2_data_freescan
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (8 preceding siblings ...)
  2016-11-05  0:08 ` [PATCH 09/16] xfs: fix btree cursor error cleanups Brian Foster
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:19   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 11/16] tools: create libxfs-diff to compare libxfses Darrick J. Wong
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 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>
---
 libxfs/libxfs_api_defs.h |    2 +-
 libxfs/libxfs_priv.h     |    8 --------
 libxfs/xfs_dir2.h        |    4 +++-
 libxfs/xfs_dir2_data.c   |   12 +++++++++++-
 repair/dir2.c            |    4 ++--
 repair/phase6.c          |    3 ++-
 6 files changed, 19 insertions(+), 14 deletions(-)


diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index d60b6c2..b7b1043 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -88,7 +88,7 @@
 #define xfs_dir_replace			libxfs_dir_replace
 #define xfs_dir2_isblock		libxfs_dir2_isblock
 #define xfs_dir2_isleaf			libxfs_dir2_isleaf
-#define __xfs_dir2_data_freescan	libxfs_dir2_data_freescan
+#define xfs_dir2_data_freescan_int	libxfs_dir2_data_freescan_int
 #define xfs_dir2_data_log_entry		libxfs_dir2_data_log_entry
 #define xfs_dir2_data_log_header	libxfs_dir2_data_log_header
 #define xfs_dir2_data_make_free		libxfs_dir2_data_make_free
diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index a101a00..f4db183 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -49,14 +49,6 @@
 #ifndef __LIBXFS_INTERNAL_XFS_H__
 #define __LIBXFS_INTERNAL_XFS_H__
 
-/*
- * Repair doesn't have a inode when it calls libxfs_dir2_data_freescan,
- * so we to work around this internally for now.
- */
-#define xfs_dir2_data_freescan(ip, hdr, loghead) \
-	__xfs_dir2_data_freescan((ip)->i_mount->m_dir_geo, \
-				 (ip)->d_ops, hdr, loghead)
-
 #include "libxfs_api_defs.h"
 #include "platform_defs.h"
 #include "xfs.h"
diff --git a/libxfs/xfs_dir2.h b/libxfs/xfs_dir2.h
index 89b9e24..0197590 100644
--- a/libxfs/xfs_dir2.h
+++ b/libxfs/xfs_dir2.h
@@ -157,9 +157,11 @@ 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(struct xfs_da_geometry *geo,
+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,
 		struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
 extern void xfs_dir2_data_log_header(struct xfs_da_args *args,
diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
index 6ae5cd2..f8def7c 100644
--- a/libxfs/xfs_dir2_data.c
+++ b/libxfs/xfs_dir2_data.c
@@ -502,7 +502,7 @@ xfs_dir2_data_freeremove(
  * Given a data block, reconstruct its bestfree map.
  */
 void
-__xfs_dir2_data_freescan(
+xfs_dir2_data_freescan_int(
 	struct xfs_da_geometry	*geo,
 	const struct xfs_dir_ops *ops,
 	struct xfs_dir2_data_hdr *hdr,
@@ -562,6 +562,16 @@ __xfs_dir2_data_freescan(
 	}
 }
 
+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.
diff --git a/repair/dir2.c b/repair/dir2.c
index 61912d1..e6415e4 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -921,8 +921,8 @@ _("bad bestfree table in block %u in directory inode %" PRIu64 ": "),
 			da_bno, ino);
 		if (!no_modify) {
 			do_warn(_("repairing table\n"));
-			libxfs_dir2_data_freescan(mp->m_dir_geo, M_DIROPS(mp),
-						  d, &i);
+			libxfs_dir2_data_freescan_int(mp->m_dir_geo,
+					M_DIROPS(mp), d, &i);
 			*dirty = 1;
 		} else {
 			do_warn(_("would repair table\n"));
diff --git a/repair/phase6.c b/repair/phase6.c
index 06eed16..399ecde 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -1883,7 +1883,8 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 "
 	}
 	*num_illegal += nbad;
 	if (needscan)
-		libxfs_dir2_data_freescan(mp->m_dir_geo, M_DIROPS(mp), d, &i);
+		libxfs_dir2_data_freescan_int(mp->m_dir_geo, M_DIROPS(mp),
+				d, &i);
 	if (needlog)
 		libxfs_dir2_data_log_header(&da, bp);
 	libxfs_defer_finish(&tp, &dfops, ip);


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

* [PATCH 11/16] tools: create libxfs-diff to compare libxfses
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (9 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 10/16] libxfs: clean up _dir2_data_freescan Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:19   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 12/16] libxfs: fix line lengths Darrick J. Wong
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Create a script to compare every file in libxfs to the same files
in another libxfs.  This is useful for comparing upstream kernel
and user progs to look for unported changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tools/libxfs-diff |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100755 tools/libxfs-diff


diff --git a/tools/libxfs-diff b/tools/libxfs-diff
new file mode 100755
index 0000000..ad69c85
--- /dev/null
+++ b/tools/libxfs-diff
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+if [ -z "$1" ] || [ ! -d "$1" ] || [ "$1" = "--help" ]; then
+	echo "Usage: $0 kernel_libxfs_dir"
+	exit 1
+fi
+
+if [ ! -d "libxfs/" ]; then
+	echo "$0: Must be run from the top level directory."
+	exit 2
+fi
+
+dir="$1"
+
+if [ ! -e "${dir}/xfs_format.h" ]; then
+	echo "${dir}: This doesn't seem to be a libxfs/ directory."
+	exit 3
+fi
+
+dir="$(readlink -m "${dir}/..")"
+
+for i in libxfs/xfs*.[ch]; do
+	kfile="${dir}/$i"
+	diff -Naurpw --label "$i" <(sed -e '/#include/d' "$i") --label "${kfile}" <(sed -e '/#include/d' "${kfile}")
+done


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

* [PATCH 12/16] libxfs: fix line lengths
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (10 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 11/16] tools: create libxfs-diff to compare libxfses Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:20   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 13/16] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs, Eric Sandeen

Fix some 80-char line length issues.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Eric Sandeen <sandeen@sandeen.net>
---
 libxfs/xfs_ialloc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 5c88b0b..efb37d3 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -2338,7 +2338,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 = (unsigned short)(offset << mp->m_sb.sb_inodelog);
+		imap->im_boffset = (unsigned short)(offset <<
+							mp->m_sb.sb_inodelog);
 		return 0;
 	}
 


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

* [PATCH 13/16] libxfs: synchronize dinode_verify with userspace
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (11 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 12/16] libxfs: fix line lengths Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:20   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 14/16] libxfs: remove useless stuff from the kernel Darrick J. Wong
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 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>
---
 libxfs/xfs_inode_buf.c |    2 +-
 libxfs/xfs_inode_buf.h |    2 --
 2 files changed, 1 insertion(+), 3 deletions(-)


diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 8732359..3f2049b 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c
@@ -378,7 +378,7 @@ xfs_log_dinode_to_disk(
 	}
 }
 
-bool
+static bool
 xfs_dinode_verify(
 	struct xfs_mount	*mp,
 	xfs_ino_t		ino,
diff --git a/libxfs/xfs_inode_buf.h b/libxfs/xfs_inode_buf.h
index 99f1821..6848a0a 100644
--- a/libxfs/xfs_inode_buf.h
+++ b/libxfs/xfs_inode_buf.h
@@ -73,8 +73,6 @@ void	xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to,
 void	xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
 void	xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
 			       struct xfs_dinode *to);
-bool	xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
-			  struct xfs_dinode *dip);
 
 bool	xfs_dinode_good_version(struct xfs_mount *mp, __u8 version);
 


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

* [PATCH 14/16] libxfs: remove useless stuff from the kernel
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (12 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 13/16] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:20   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 15/16] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-xfs

Evidently the libxfs-apply script sucked in some fs/xfs/ content from
the kernel patches and an extra redefinition of _bmap_search_extents.
We don't need this, so get rid of it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_rmap_item.c |    0 
 fs/xfs/xfs_rmap_item.h |    0 
 libxfs/xfs_bmap.h      |    7 -------
 3 files changed, 7 deletions(-)
 delete mode 100644 fs/xfs/xfs_rmap_item.c
 delete mode 100644 fs/xfs/xfs_rmap_item.h


diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
deleted file mode 100644
index e69de29..0000000
diff --git a/fs/xfs/xfs_rmap_item.h b/fs/xfs/xfs_rmap_item.h
deleted file mode 100644
index e69de29..0000000
diff --git a/libxfs/xfs_bmap.h b/libxfs/xfs_bmap.h
index 482e151..7cae6ec 100644
--- a/libxfs/xfs_bmap.h
+++ b/libxfs/xfs_bmap.h
@@ -246,13 +246,6 @@ int	xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
 		struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *prev,
 		xfs_extnum_t *lastx, int eof);
 
-struct xfs_bmbt_rec_host *
-	xfs_bmap_search_extents(struct xfs_inode *ip, xfs_fileoff_t bno,
-				int fork, int *eofp, xfs_extnum_t *lastxp,
-				struct xfs_bmbt_irec *gotp,
-				struct xfs_bmbt_irec *prevp);
-
-
 enum xfs_bmap_intent_type {
 	XFS_BMAP_MAP = 1,
 	XFS_BMAP_UNMAP,


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

* [PATCH 15/16] xfs: check return value of _trans_reserve_quota_nblks
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (13 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 14/16] libxfs: remove useless stuff from the kernel Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:21   ` Christoph Hellwig
  2016-11-05  0:09 ` [PATCH 16/16] xfs: check minimum block size for CRC filesystems Darrick J. Wong
  2016-11-22 18:26 ` [PATCH 17/16] libxfs-apply: port to stgit Darrick J. Wong
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 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>
---
 libxfs/xfs_bmap.c |    2 ++
 1 file changed, 2 insertions(+)


diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index 165d863..0e2f450 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -4897,6 +4897,8 @@ xfs_bmap_del_extent_delay(
 	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] 39+ messages in thread

* [PATCH 16/16] xfs: check minimum block size for CRC filesystems
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (14 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 15/16] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
@ 2016-11-05  0:09 ` Darrick J. Wong
  2016-11-15 10:22   ` Christoph Hellwig
  2016-11-22 18:26 ` [PATCH 17/16] libxfs-apply: port to stgit Darrick J. Wong
  16 siblings, 1 reply; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-05  0:09 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>
---
 libxfs/xfs_sb.c |    7 +++++++
 1 file changed, 7 insertions(+)


diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index adc47e2..46e57aa 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -259,6 +259,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;
+	}
+
 	/*
 	 * Currently only very few inode sizes are supported.
 	 */


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

* Re: [PATCH 01/16] xfs_repair: fix some potential null pointer deferences
  2016-11-05  0:08 ` [PATCH 01/16] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
@ 2016-11-15 10:14   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:14 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:03PM -0700, Darrick J. Wong wrote:
> Fix some potential NULL pointer deferences that Coverity pointed out,
> and remove a trivial dead integer check.
> 
> Coverity-id: 1375789, 1375790, 1375791, 1375792
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

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

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

* Re: [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check
  2016-11-05  0:08 ` [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
@ 2016-11-15 10:15   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:10PM -0700, Darrick J. Wong wrote:
> Make the reverse mapping owner check actually validate inode numbers.
> 
> Coverity-id: 1371628
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  repair/scan.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/repair/scan.c b/repair/scan.c
> index 0e13581..b9ef4dc 100644
> --- a/repair/scan.c
> +++ b/repair/scan.c
> @@ -1052,8 +1052,12 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
>  			}
>  
>  			/* Look for impossible owners. */
> -			if (!(owner > 0 || (owner > XFS_RMAP_OWN_MIN &&
> -					    owner <= XFS_RMAP_OWN_FS)))
> +			if (!((owner > XFS_RMAP_OWN_MIN &&
> +			       owner <= XFS_RMAP_OWN_FS) ||
> +			      (XFS_INO_TO_AGNO(mp, owner) < mp->m_sb.sb_agcount &&
> +			       XFS_AGINO_TO_AGBNO(mp,
> +					XFS_INO_TO_AGINO(mp, owner)) <
> +					mp->m_sb.sb_agblocks)))

This condition looks complex enough to break it out into a helper.


Except for that this looks fine:

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

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

* Re: [PATCH 03/16] xfs_io: fix libxfs naming violation
  2016-11-05  0:08 ` [PATCH 03/16] xfs_io: fix libxfs naming violation Darrick J. Wong
@ 2016-11-15 10:15   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:17PM -0700, Darrick J. Wong wrote:
> All the calls to libxfs code should start with 'libxfs'
> per libxfs_api_defs.h.

Looks fine (although I'm not a big fan of the big rename in general):

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

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

* Re: [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers
  2016-11-05  0:08 ` [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers Darrick J. Wong
@ 2016-11-15 10:16   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:16 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:24PM -0700, Darrick J. Wong wrote:
> xfs_btree_sblock_v5hdr_verify already checks _hascrc, so we can
> remove it from the verifier functions.  For whatever reason this
> change made it into the kernel but not xfsprogs.

Looks fine,

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

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

* Re: [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-05  0:08 ` [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
@ 2016-11-15 10:16   ` Christoph Hellwig
  2016-11-15 13:41     ` Eric Sandeen
  2016-11-22 18:21   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 1 reply; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:16 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: david, darrick.wong, linux-xfs, Dave Chinner

On Fri, Nov 04, 2016 at 05:08:30PM -0700, Eric Sandeen wrote:
> >From c400ee3ed1b13d45adde68e12254dc6ab6977b59 Mon Sep 17 00:00:00 2001

It should claim to be from Eric here I think..

And mention that it's a port from a kernel commit.

Otherwise looks fine:

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

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

* Re: [PATCH 06/16] libxfs: refactor btree crc verifier
  2016-11-05  0:08 ` [PATCH 06/16] libxfs: refactor btree crc verifier Darrick J. Wong
@ 2016-11-15 10:17   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:36PM -0700, Darrick J. Wong wrote:
> In a65d8d293b ("libxfs: validate metadata LSNs against log on v5
> superblocks") the hascrc check was modified to use the helper mp
> variable in the kernel.  This was left out of the xfsprogs patch, so
> change it 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] 39+ messages in thread

* Re: [PATCH 07/16] libxfs: fix whitespace to match the kernel
  2016-11-05  0:08 ` [PATCH 07/16] libxfs: fix whitespace to match the kernel Darrick J. Wong
@ 2016-11-15 10:17   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:42PM -0700, Darrick J. Wong wrote:
> Fix some minor whitespace errors so that my automated libxfs diff
> scanning will stop reporting this.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

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

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

* Re: [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid
  2016-11-05  0:08 ` [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid Darrick J. Wong
@ 2016-11-15 10:17   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:08:48PM -0700, Darrick J. Wong wrote:
> The kernel's version of this function returns bool, so do so 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] 39+ messages in thread

* Re: [PATCH 09/16] xfs: fix btree cursor error cleanups
  2016-11-05  0:08 ` [PATCH 09/16] xfs: fix btree cursor error cleanups Brian Foster
@ 2016-11-15 10:18   ` Christoph Hellwig
  2016-11-22 18:23   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:18 UTC (permalink / raw)
  To: Brian Foster; +Cc: david, darrick.wong, linux-xfs, Christoph Hellwig

Looks fine modulo the wrong From lines:

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

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

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

On Fri, Nov 04, 2016 at 05:09:01PM -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] 39+ messages in thread

* Re: [PATCH 11/16] tools: create libxfs-diff to compare libxfses
  2016-11-05  0:09 ` [PATCH 11/16] tools: create libxfs-diff to compare libxfses Darrick J. Wong
@ 2016-11-15 10:19   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:19 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:09:07PM -0700, Darrick J. Wong wrote:
> Create a script to compare every file in libxfs to the same files
> in another libxfs.  This is useful for comparing upstream kernel
> and user progs to look for unported changes.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

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

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

* Re: [PATCH 12/16] libxfs: fix line lengths
  2016-11-05  0:09 ` [PATCH 12/16] libxfs: fix line lengths Darrick J. Wong
@ 2016-11-15 10:20   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:20 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs, Eric Sandeen

On Fri, Nov 04, 2016 at 05:09:14PM -0700, Darrick J. Wong wrote:
> Fix some 80-char line length issues.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reported-by: Eric Sandeen <sandeen@sandeen.net>
> ---

Is this a port from the kernel tree?  Otherwise looks ok:

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

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

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

On Fri, Nov 04, 2016 at 05:09:20PM -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] 39+ messages in thread

* Re: [PATCH 14/16] libxfs: remove useless stuff from the kernel
  2016-11-05  0:09 ` [PATCH 14/16] libxfs: remove useless stuff from the kernel Darrick J. Wong
@ 2016-11-15 10:20   ` Christoph Hellwig
  0 siblings, 0 replies; 39+ messages in thread
From: Christoph Hellwig @ 2016-11-15 10:20 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs

On Fri, Nov 04, 2016 at 05:09:26PM -0700, Darrick J. Wong wrote:
> Evidently the libxfs-apply script sucked in some fs/xfs/ content from
> the kernel patches and an extra redefinition of _bmap_search_extents.
> We don't need this, so get rid of it.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks fine,

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

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

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

On Fri, Nov 04, 2016 at 05:09:32PM -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] 39+ messages in thread

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

> +	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;
> +	}

No need to uglify mount, which is a slow path with unlikely annotations.

Otherwise looks fine:

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

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

* Re: [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-15 10:16   ` Christoph Hellwig
@ 2016-11-15 13:41     ` Eric Sandeen
  2016-11-16  5:21       ` Dave Chinner
  0 siblings, 1 reply; 39+ messages in thread
From: Eric Sandeen @ 2016-11-15 13:41 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: david, darrick.wong, linux-xfs, Dave Chinner

On 11/15/16 4:16 AM, Christoph Hellwig wrote:
> On Fri, Nov 04, 2016 at 05:08:30PM -0700, Eric Sandeen wrote:
>> >From c400ee3ed1b13d45adde68e12254dc6ab6977b59 Mon Sep 17 00:00:00 2001
> 
> It should claim to be from Eric here I think..

> And mention that it's a port from a kernel commit.

I suppose - do we have a clear policy on that?  What should the format
be for kernel<->userspace cross-ports in terms of From:, SoB:, etc?

I guess the libxfs-apply script in tools/ implicitly defines that, i.e. -

        # We want to format it like a normal patch with a line to say what repo
        # and commit it was sourced from:
        #
        # xfs: make several functions static
        #
        # From: Eric Sandeen <sandeen@sandeen.net>
        #
        # Source kernel commit: 0d5a75e9e23ee39cd0d8a167393dcedb4f0f47b2
        #
        # <body>

-Eric

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


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

* Re: [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-15 13:41     ` Eric Sandeen
@ 2016-11-16  5:21       ` Dave Chinner
  2016-11-22 18:21         ` Darrick J. Wong
  0 siblings, 1 reply; 39+ messages in thread
From: Dave Chinner @ 2016-11-16  5:21 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, darrick.wong, linux-xfs, Dave Chinner

On Tue, Nov 15, 2016 at 07:41:19AM -0600, Eric Sandeen wrote:
> On 11/15/16 4:16 AM, Christoph Hellwig wrote:
> > On Fri, Nov 04, 2016 at 05:08:30PM -0700, Eric Sandeen wrote:
> >> >From c400ee3ed1b13d45adde68e12254dc6ab6977b59 Mon Sep 17 00:00:00 2001
> > 
> > It should claim to be from Eric here I think..
> 
> > And mention that it's a port from a kernel commit.
> 
> I suppose - do we have a clear policy on that?  What should the format
> be for kernel<->userspace cross-ports in terms of From:, SoB:, etc?
> 
> I guess the libxfs-apply script in tools/ implicitly defines that, i.e. -
> 
>         # We want to format it like a normal patch with a line to say what repo
>         # and commit it was sourced from:
>         #
>         # xfs: make several functions static
>         #
>         # From: Eric Sandeen <sandeen@sandeen.net>
>         #
>         # Source kernel commit: 0d5a75e9e23ee39cd0d8a167393dcedb4f0f47b2
>         #
>         # <body>

Yes, exactly. I asked Darricki last week to regenerate the patches
with this commit message problem using the libxfs-apply tool as it
handles all this commit reference/orignal author reformatting
automatically now.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* [PATCH v2 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-05  0:08 ` [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
  2016-11-15 10:16   ` Christoph Hellwig
@ 2016-11-22 18:21   ` Darrick J. Wong
  1 sibling, 0 replies; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-22 18:21 UTC (permalink / raw)
  To: david; +Cc: Eric Sandeen, linux-xfs, Dave Chinner

From: Eric Sandeen <sandeen@redhat.com>

Source kernel commit: c400ee3ed1b13d45adde68e12254dc6ab6977b59

It's entirely possible for userspace to ask for an xattr which
does not exist.

Normally, there is no problem whatsoever when we ask for such
a thing, but when we look at an obfuscated metadump image
on a debug kernel with selinux, we trip over this ASSERT in
xfs_da3_path_shift():

*result = -ENOENT;      /* we're out of our tree */
ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);

It (more or less) only shows up in the above scenario, because
xfs_metadump obfuscates attr names, but chooses names which
keep the same hash value - and xfs_da3_node_lookup_int does:

if (((retval == -ENOENT) || (retval == -ENOATTR)) &&
(blk->hashval == args->hashval)) {
error = xfs_da3_path_shift(state, &state->path, 1, 1,
&retval);

IOWS, we only get down to the xfs_da3_path_shift() ASSERT
if we are looking for an xattr which doesn't exist, but we
find xattrs on disk which have the same hash, and so might be
a hash collision, so we try the path shift.  When *that*
fails to find what we're looking for, we hit the assert about
XFS_DA_OP_OKNOENT.

Simply setting XFS_DA_OP_OKNOENT in xfs_attr_get solves this
rather corner-case problem with no ill side effects.  It's
fine for an attr name lookup to fail.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_attr.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c
index c7f0afa..60513f9 100644
--- a/libxfs/xfs_attr.c
+++ b/libxfs/xfs_attr.c
@@ -135,6 +135,8 @@ xfs_attr_get(
 
 	args.value = value;
 	args.valuelen = *valuelenp;
+	/* Entirely possible to look up a name which doesn't exist */
+	args.op_flags = XFS_DA_OP_OKNOENT;
 
 	lock_mode = xfs_ilock_attr_map_shared(ip);
 	if (!xfs_inode_hasattr(ip))

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

* Re: [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get
  2016-11-16  5:21       ` Dave Chinner
@ 2016-11-22 18:21         ` Darrick J. Wong
  0 siblings, 0 replies; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-22 18:21 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Eric Sandeen, Christoph Hellwig, linux-xfs, Dave Chinner

On Wed, Nov 16, 2016 at 04:21:16PM +1100, Dave Chinner wrote:
> On Tue, Nov 15, 2016 at 07:41:19AM -0600, Eric Sandeen wrote:
> > On 11/15/16 4:16 AM, Christoph Hellwig wrote:
> > > On Fri, Nov 04, 2016 at 05:08:30PM -0700, Eric Sandeen wrote:
> > >> >From c400ee3ed1b13d45adde68e12254dc6ab6977b59 Mon Sep 17 00:00:00 2001
> > > 
> > > It should claim to be from Eric here I think..
> > 
> > > And mention that it's a port from a kernel commit.
> > 
> > I suppose - do we have a clear policy on that?  What should the format
> > be for kernel<->userspace cross-ports in terms of From:, SoB:, etc?
> > 
> > I guess the libxfs-apply script in tools/ implicitly defines that, i.e. -
> > 
> >         # We want to format it like a normal patch with a line to say what repo
> >         # and commit it was sourced from:
> >         #
> >         # xfs: make several functions static
> >         #
> >         # From: Eric Sandeen <sandeen@sandeen.net>
> >         #
> >         # Source kernel commit: 0d5a75e9e23ee39cd0d8a167393dcedb4f0f47b2
> >         #
> >         # <body>
> 
> Yes, exactly. I asked Darricki last week to regenerate the patches
> with this commit message problem using the libxfs-apply tool as it
> handles all this commit reference/orignal author reformatting
> automatically now.

Heh, I fixed up the patches and forgot to send out v2 patches.
I'll do that now.

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> 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] 39+ messages in thread

* [PATCH v2 09/16] xfs: fix btree cursor error cleanups
  2016-11-05  0:08 ` [PATCH 09/16] xfs: fix btree cursor error cleanups Brian Foster
  2016-11-15 10:18   ` Christoph Hellwig
@ 2016-11-22 18:23   ` Darrick J. Wong
  1 sibling, 0 replies; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-22 18:23 UTC (permalink / raw)
  To: david; +Cc: Brian Foster, linux-xfs, Christoph Hellwig

From: Brian Foster <bfoster@redhat.com>

Source kernel commit: f307080a626569f89bc8fbad9f936b307aded877

The btree cursor cleanup function takes an error parameter that
affects how buffers are released from the cursor. All buffers are
released in the event of error. Several callers do not specify the
XFS_BTREE_ERROR flag in the event of error, however. This can cause
buffers to hang around locked or with an elevated hold count and
thus lead to umount hangs in the event of errors.

Fix up the xfs_btree_del_cursor() callers to pass XFS_BTREE_ERROR if
the cursor is being torn down due to error.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 libxfs/xfs_ialloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index f0f243e..5c88b0b 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -2232,7 +2232,7 @@ xfs_imap_lookup(
 	}
 
 	xfs_trans_brelse(tp, agbp);
-	xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
+	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
 	if (error)
 		return error;
 

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

* [PATCH 17/16] libxfs-apply: port to stgit
  2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
                   ` (15 preceding siblings ...)
  2016-11-05  0:09 ` [PATCH 16/16] xfs: check minimum block size for CRC filesystems Darrick J. Wong
@ 2016-11-22 18:26 ` Darrick J. Wong
  16 siblings, 0 replies; 39+ messages in thread
From: Darrick J. Wong @ 2016-11-22 18:26 UTC (permalink / raw)
  To: david; +Cc: linux-xfs

Teach libxfs-apply how to talk to a stgit repository
and fix a minor typo in the guilt hunk of apply_patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tools/libxfs-apply |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tools/libxfs-apply b/tools/libxfs-apply
index 8df1a49..5cf0879 100755
--- a/tools/libxfs-apply
+++ b/tools/libxfs-apply
@@ -66,6 +66,7 @@ PATCH=
 COMMIT_ID=
 VERBOSE=
 GUILT=0
+STGIT=0
 
 while [ $# -gt 0 ]; do
 	case "$1" in
@@ -95,6 +96,12 @@ if [ $? -eq 0 ]; then
 	GUILT=1
 fi
 
+# Are we using stgit? This works even if no patch is applied.
+stg top &> /dev/null
+if [ $? -eq 0 ]; then
+	STGIT=1
+fi
+
 #this is pulled from the guilt code to handle commit ids sanely.
 # usage: munge_hash_range <hash range>
 #
@@ -332,7 +339,27 @@ apply_patch()
 			guilt refresh
 		else
 			echo "Guilt push failed!"
-			read -r -p "Skip of Fail [s|F]? " response
+			read -r -p "Skip or Fail [s|F]? " response
+			if [ -z "$response" -o "$response" != "s" ]; then
+				echo "Force push patch, fix and refresh."
+				echo "Restart from commit $_current_commit"
+				fail "Manual cleanup required!"
+			else
+				echo "Skipping. Manual series file cleanup needed!"
+			fi
+		fi
+	elif [ $STGIT -eq 1 ]; then
+		[ -n "$VERBOSE" ] || echo "$REPO looks like a stgit directory."
+		PATCHES=`stg series | wc -l`
+		if [ -n "$VERBOSE" -a $PATCHES -gt 0 ]; then
+			echo -n "Top patch is: "
+			stg top
+		fi
+
+		stg import -n $_patch_name $_new_patch.2
+		if [ $? -ne 0 ]; then
+			echo "stgit push failed!"
+			read -r -p "Skip or Fail [s|F]? " response
 			if [ -z "$response" -o "$response" != "s" ]; then
 				echo "Force push patch, fix and refresh."
 				echo "Restart from commit $_current_commit"

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

end of thread, other threads:[~2016-11-22 18:26 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-05  0:07 [PATCH v2 00/16] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
2016-11-05  0:08 ` [PATCH 01/16] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
2016-11-15 10:14   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 02/16] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
2016-11-15 10:15   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 03/16] xfs_io: fix libxfs naming violation Darrick J. Wong
2016-11-15 10:15   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 04/16] libxfs: remove unnecessary hascrc test in btree verifiers Darrick J. Wong
2016-11-15 10:16   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 05/16] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
2016-11-15 10:16   ` Christoph Hellwig
2016-11-15 13:41     ` Eric Sandeen
2016-11-16  5:21       ` Dave Chinner
2016-11-22 18:21         ` Darrick J. Wong
2016-11-22 18:21   ` [PATCH v2 " Darrick J. Wong
2016-11-05  0:08 ` [PATCH 06/16] libxfs: refactor btree crc verifier Darrick J. Wong
2016-11-15 10:17   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 07/16] libxfs: fix whitespace to match the kernel Darrick J. Wong
2016-11-15 10:17   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 08/16] libxfs: return bool from sb_version_hasmetauuid Darrick J. Wong
2016-11-15 10:17   ` Christoph Hellwig
2016-11-05  0:08 ` [PATCH 09/16] xfs: fix btree cursor error cleanups Brian Foster
2016-11-15 10:18   ` Christoph Hellwig
2016-11-22 18:23   ` [PATCH v2 " Darrick J. Wong
2016-11-05  0:09 ` [PATCH 10/16] libxfs: clean up _dir2_data_freescan Darrick J. Wong
2016-11-15 10:19   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 11/16] tools: create libxfs-diff to compare libxfses Darrick J. Wong
2016-11-15 10:19   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 12/16] libxfs: fix line lengths Darrick J. Wong
2016-11-15 10:20   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 13/16] libxfs: synchronize dinode_verify with userspace Darrick J. Wong
2016-11-15 10:20   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 14/16] libxfs: remove useless stuff from the kernel Darrick J. Wong
2016-11-15 10:20   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 15/16] xfs: check return value of _trans_reserve_quota_nblks Darrick J. Wong
2016-11-15 10:21   ` Christoph Hellwig
2016-11-05  0:09 ` [PATCH 16/16] xfs: check minimum block size for CRC filesystems Darrick J. Wong
2016-11-15 10:22   ` Christoph Hellwig
2016-11-22 18:26 ` [PATCH 17/16] libxfs-apply: port to stgit Darrick J. Wong

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.