All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] xfs_io: detect the '-R' option in getopt
@ 2016-01-23  0:35 Darrick J. Wong
  2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  0:35 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: xfs

Configure getopt to accept the -R argument to pwrite.

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


diff --git a/io/pwrite.c b/io/pwrite.c
index fd9114d..c6efee9 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -259,7 +259,7 @@ pwrite_f(
 	init_cvtnum(&fsblocksize, &fssectsize);
 	bsize = fsblocksize;
 
-	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
+	while ((c = getopt(argc, argv, "b:Cdf:i:qRs:S:uV:wWZ:")) != EOF) {
 		switch (c) {
 		case 'b':
 			tmp = cvtnum(fsblocksize, fssectsize, optarg);

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
@ 2016-01-23  0:35 ` Darrick J. Wong
  2016-02-01 15:17   ` Brian Foster
  2016-02-11 23:48   ` Darrick J. Wong
  2016-01-23  0:35 ` [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  0:35 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: xfs

Create a macro to generate btree height calculator functions.
This will be used (much) later when we get to the refcount
btree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_bmap.c       |   18 +-----------------
 libxfs/xfs_bmap_btree.c |    9 +++++++++
 libxfs/xfs_bmap_btree.h |    3 +++
 libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
 libxfs/xfs_btree.h      |    3 +++
 5 files changed, 44 insertions(+), 17 deletions(-)


diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index aef7cf3..c134765 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
 	xfs_inode_t	*ip,		/* incore inode pointer */
 	xfs_filblks_t	len)		/* delayed extent length */
 {
-	int		level;		/* btree level number */
-	int		maxrecs;	/* maximum record count at this level */
-	xfs_mount_t	*mp;		/* mount structure */
 	xfs_filblks_t	rval;		/* return value */
 
-	mp = ip->i_mount;
-	maxrecs = mp->m_bmap_dmxr[0];
-	for (level = 0, rval = 0;
-	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
-	     level++) {
-		len += maxrecs - 1;
-		do_div(len, maxrecs);
-		rval += len;
-		if (len == 1)
-			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
-				level - 1;
-		if (level == 0)
-			maxrecs = mp->m_bmap_dmxr[1];
-	}
+	rval = xfs_bmbt_calc_size(ip->i_mount, len);
 	return rval;
 }
 
diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c
index 2ef1836..3c595e2 100644
--- a/libxfs/xfs_bmap_btree.c
+++ b/libxfs/xfs_bmap_btree.c
@@ -880,3 +880,12 @@ xfs_bmbt_change_owner(
 	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
 	return error;
 }
+
+xfs_filblks_t
+xfs_bmbt_calc_size(
+	struct xfs_mount	*mp,
+	unsigned long		len)
+{
+	return xfs_btree_calc_size(mp, mp->m_bmap_dmxr,
+			XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), len);
+}
diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h
index 819a8a4..04bc6e2 100644
--- a/libxfs/xfs_bmap_btree.h
+++ b/libxfs/xfs_bmap_btree.h
@@ -140,4 +140,7 @@ extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
 extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
 		struct xfs_trans *, struct xfs_inode *, int);
 
+extern xfs_filblks_t xfs_bmbt_calc_size(struct xfs_mount *mp,
+		unsigned long len);
+
 #endif	/* __XFS_BMAP_BTREE_H__ */
diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
index 658f27e..d5f16c5 100644
--- a/libxfs/xfs_btree.c
+++ b/libxfs/xfs_btree.c
@@ -4081,6 +4081,34 @@ xfs_btree_change_owner(
 	return 0;
 }
 
+/*
+ * xfs_btree_calc_size() -- Calculate the number of blocks needed to store
+ *			    a given number of records.
+ */
+xfs_filblks_t
+xfs_btree_calc_size(
+	struct xfs_mount	*mp,
+	uint			*limits,
+	int			maxlevels,
+	unsigned long		len)
+{
+	int			level;
+	int			maxrecs;
+	xfs_filblks_t		rval;
+
+	maxrecs = limits[0];
+	for (level = 0, rval = 0; level < maxlevels; level++) {
+		len += maxrecs - 1;
+		do_div(len, maxrecs);
+		rval += len;
+		if (len == 1)
+			return rval + maxlevels - level - 1;
+		if (level == 0)
+			maxrecs = limits[1];
+	}
+	return rval;
+}
+
 /**
  * xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
  *				      btree block
diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h
index 48cb251..b25ffd3 100644
--- a/libxfs/xfs_btree.h
+++ b/libxfs/xfs_btree.h
@@ -465,6 +465,9 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
 #define XFS_BTREE_TRACE_ARGR(c, r)
 #define	XFS_BTREE_TRACE_CURSOR(c, t)
 
+xfs_filblks_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits,
+		int maxlevels, unsigned long len);
+
 bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
 bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
  2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
@ 2016-01-23  0:35 ` Darrick J. Wong
  2016-01-23  5:08   ` Eric Sandeen
  2016-01-23  0:35 ` [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize Darrick J. Wong
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  0:35 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: xfs

Move the shortform attr structure definition to the same place as the
other attribute structure definitions for consistency and also so that
xfs/122 verifies the structure size.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/xfs_attr_sf.h    |   16 ----------------
 libxfs/xfs_da_format.h  |   16 ++++++++++++++++
 libxfs/xfs_inode_fork.c |    1 +
 3 files changed, 17 insertions(+), 16 deletions(-)


diff --git a/libxfs/xfs_attr_sf.h b/libxfs/xfs_attr_sf.h
index 919756e..90928bb 100644
--- a/libxfs/xfs_attr_sf.h
+++ b/libxfs/xfs_attr_sf.h
@@ -24,22 +24,6 @@
  * Small attribute lists are packed as tightly as possible so as
  * to fit into the literal area of the inode.
  */
-
-/*
- * Entries are packed toward the top as tight as possible.
- */
-typedef struct xfs_attr_shortform {
-	struct xfs_attr_sf_hdr {	/* constant-structure header block */
-		__be16	totsize;	/* total bytes in shortform list */
-		__u8	count;	/* count of active entries */
-	} hdr;
-	struct xfs_attr_sf_entry {
-		__uint8_t namelen;	/* actual length of name (no NULL) */
-		__uint8_t valuelen;	/* actual length of value (no NULL) */
-		__uint8_t flags;	/* flags bits (see xfs_attr_leaf.h) */
-		__uint8_t nameval[1];	/* name & value bytes concatenated */
-	} list[1];			/* variable sized array */
-} xfs_attr_shortform_t;
 typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
 typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
 
diff --git a/libxfs/xfs_da_format.h b/libxfs/xfs_da_format.h
index b14bbd6..8d4d8bc 100644
--- a/libxfs/xfs_da_format.h
+++ b/libxfs/xfs_da_format.h
@@ -641,6 +641,22 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
  */
 #define XFS_ATTR_LEAF_MAPSIZE	3	/* how many freespace slots */
 
+/*
+ * Entries are packed toward the top as tight as possible.
+ */
+typedef struct xfs_attr_shortform {
+	struct xfs_attr_sf_hdr {	/* constant-structure header block */
+		__be16	totsize;	/* total bytes in shortform list */
+		__u8	count;	/* count of active entries */
+	} hdr;
+	struct xfs_attr_sf_entry {
+		__uint8_t namelen;	/* actual length of name (no NULL) */
+		__uint8_t valuelen;	/* actual length of value (no NULL) */
+		__uint8_t flags;	/* flags bits (see xfs_attr_leaf.h) */
+		__uint8_t nameval[1];	/* name & value bytes concatenated */
+	} list[1];			/* variable sized array */
+} xfs_attr_shortform_t;
+
 typedef struct xfs_attr_leaf_map {	/* RLE map of free bytes */
 	__be16	base;			  /* base of free region */
 	__be16	size;			  /* length of free region */
diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
index e1968b4..f40649e 100644
--- a/libxfs/xfs_inode_fork.c
+++ b/libxfs/xfs_inode_fork.c
@@ -27,6 +27,7 @@
 #include "xfs_bmap.h"
 #include "xfs_trace.h"
 #include "xfs_attr_sf.h"
+#include "xfs_da_format.h"
 
 kmem_zone_t *xfs_ifork_zone;
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
  2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
  2016-01-23  0:35 ` [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
@ 2016-01-23  0:35 ` Darrick J. Wong
  2016-02-01 15:18   ` Brian Foster
  2016-01-23  0:35 ` [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout Darrick J. Wong
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  0:35 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: xfs

When the block size is large enough that multiple inode chunks can fit
in a single block (e.g. 64k blocks, 512 byte inodes) we must calculate
the per-chunk block size and the buffer offset correctly so that check
actually examines the correct metadata.

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


diff --git a/db/check.c b/db/check.c
index 838db53..4e2768e 100644
--- a/db/check.c
+++ b/db/check.c
@@ -4386,6 +4386,7 @@ scanfunc_ino(
 	__u16			holemask;
 	xfs_agino_t		rino;
 	xfs_extlen_t		cblocks;
+	int			bufoff;
 
 	if (be32_to_cpu(block->bb_magic) != XFS_IBT_MAGIC &&
 	    be32_to_cpu(block->bb_magic) != XFS_IBT_CRC_MAGIC) {
@@ -4455,6 +4456,8 @@ scanfunc_ino(
 				rino = agino + startidx;
 				cblocks = (endidx - startidx) >>
 						mp->m_sb.sb_inopblog;
+				if (cblocks == 0)
+					cblocks = 1;
 
 				/* Check the sparse chunk alignment */
 				if (sparse &&
@@ -4468,8 +4471,9 @@ scanfunc_ino(
 				}
 
 				/* Check the block map */
-				set_dbmap(seqno, XFS_AGINO_TO_AGBNO(mp, rino),
-					cblocks, DBM_INODE, seqno, bno);
+				if (XFS_AGINO_TO_OFFSET(mp, rino) == 0)
+					set_dbmap(seqno, XFS_AGINO_TO_AGBNO(mp, rino),
+						cblocks, DBM_INODE, seqno, bno);
 
 				push_cur();
 				set_cur(&typtab[TYP_INODE],
@@ -4489,14 +4493,15 @@ scanfunc_ino(
 				}
 
 				/* Examine each inode in this chunk */
-				for (j = startidx; j < endidx; j++) {
+				bufoff = ((XFS_AGINO_TO_OFFSET(mp, rino) - startidx) << mp->m_sb.sb_inodelog);
+				for (j = startidx; j < endidx; j++, bufoff += (1 << mp->m_sb.sb_inodelog)) {
 					if (ino_issparse(&rp[i], j))
 						continue;
 					isfree = XFS_INOBT_IS_FREE_DISK(&rp[i], j);
 					if (isfree)
 						nfree++;
 					process_inode(agf, agino + j,
-						(xfs_dinode_t *)((char *)iocur_top->data + ((j - startidx) << mp->m_sb.sb_inodelog)),
+						(xfs_dinode_t *)((char *)iocur_top->data + bufoff),
 							isfree);
 				}
 				pop_cur();

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
                   ` (2 preceding siblings ...)
  2016-01-23  0:35 ` [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize Darrick J. Wong
@ 2016-01-23  0:35 ` Darrick J. Wong
  2016-02-02  5:14   ` Dave Chinner
  2016-01-23  4:55 ` [PATCH 1/5] xfs_io: detect the '-R' option in getopt Eric Sandeen
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  0:35 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: xfs

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


diff --git a/io/reflink.c b/io/reflink.c
index def01be..a09e82d 100644
--- a/io/reflink.c
+++ b/io/reflink.c
@@ -78,11 +78,13 @@ dedupe_ioctl(
 			goto done;
 		}
 		if (info->status < 0) {
-			printf("dedupe: %s\n", _(strerror(-info->status)));
+			fprintf(stderr, "dedupe: %s\n",
+					_(strerror(-info->status)));
 			goto done;
 		}
 		if (info->status == XFS_EXTENT_DATA_DIFFERS) {
-			printf(_("Extents did not match.\n"));
+			fprintf(stderr, "dedupe: %s\n",
+					_("Extents did not match."));
 			goto done;
 		}
 		if (args->length != 0 &&

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 1/5] xfs_io: detect the '-R' option in getopt
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
                   ` (3 preceding siblings ...)
  2016-01-23  0:35 ` [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout Darrick J. Wong
@ 2016-01-23  4:55 ` Eric Sandeen
  2016-01-23  6:18   ` Darrick J. Wong
  2016-01-27  0:58 ` [PATCH 1/5 v2] " Darrick J. Wong
  2016-01-27  4:44 ` [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting Darrick J. Wong
  6 siblings, 1 reply; 23+ messages in thread
From: Eric Sandeen @ 2016-01-23  4:55 UTC (permalink / raw)
  To: xfs

On 1/22/16 6:35 PM, Darrick J. Wong wrote:
> Configure getopt to accept the -R argument to pwrite.

Did you have anything against "F" and "B"? :)

(They're missing too but in the case statements & help)

-Eric

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  io/pwrite.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> diff --git a/io/pwrite.c b/io/pwrite.c
> index fd9114d..c6efee9 100644
> --- a/io/pwrite.c
> +++ b/io/pwrite.c
> @@ -259,7 +259,7 @@ pwrite_f(
>  	init_cvtnum(&fsblocksize, &fssectsize);
>  	bsize = fsblocksize;
>  
> -	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
> +	while ((c = getopt(argc, argv, "b:Cdf:i:qRs:S:uV:wWZ:")) != EOF) {
>  		switch (c) {
>  		case 'b':
>  			tmp = cvtnum(fsblocksize, fssectsize, optarg);
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h
  2016-01-23  0:35 ` [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
@ 2016-01-23  5:08   ` Eric Sandeen
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Sandeen @ 2016-01-23  5:08 UTC (permalink / raw)
  To: xfs

On 1/22/16 6:35 PM, Darrick J. Wong wrote:
> Move the shortform attr structure definition to the same place as the
> other attribute structure definitions for consistency and also so that
> xfs/122 verifies the structure size.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  libxfs/xfs_attr_sf.h    |   16 ----------------
>  libxfs/xfs_da_format.h  |   16 ++++++++++++++++
>  libxfs/xfs_inode_fork.c |    1 +
>  3 files changed, 17 insertions(+), 16 deletions(-)
> 
> 
> diff --git a/libxfs/xfs_attr_sf.h b/libxfs/xfs_attr_sf.h
> index 919756e..90928bb 100644
> --- a/libxfs/xfs_attr_sf.h
> +++ b/libxfs/xfs_attr_sf.h
> @@ -24,22 +24,6 @@
>   * Small attribute lists are packed as tightly as possible so as
>   * to fit into the literal area of the inode.
>   */
> -
> -/*
> - * Entries are packed toward the top as tight as possible.
> - */
> -typedef struct xfs_attr_shortform {
> -	struct xfs_attr_sf_hdr {	/* constant-structure header block */
> -		__be16	totsize;	/* total bytes in shortform list */
> -		__u8	count;	/* count of active entries */
> -	} hdr;
> -	struct xfs_attr_sf_entry {
> -		__uint8_t namelen;	/* actual length of name (no NULL) */
> -		__uint8_t valuelen;	/* actual length of value (no NULL) */
> -		__uint8_t flags;	/* flags bits (see xfs_attr_leaf.h) */
> -		__uint8_t nameval[1];	/* name & value bytes concatenated */
> -	} list[1];			/* variable sized array */
> -} xfs_attr_shortform_t;
>  typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
>  typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
>  
> diff --git a/libxfs/xfs_da_format.h b/libxfs/xfs_da_format.h
> index b14bbd6..8d4d8bc 100644
> --- a/libxfs/xfs_da_format.h
> +++ b/libxfs/xfs_da_format.h
> @@ -641,6 +641,22 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
>   */
>  #define XFS_ATTR_LEAF_MAPSIZE	3	/* how many freespace slots */
>  
> +/*
> + * Entries are packed toward the top as tight as possible.
> + */
> +typedef struct xfs_attr_shortform {
> +	struct xfs_attr_sf_hdr {	/* constant-structure header block */
> +		__be16	totsize;	/* total bytes in shortform list */
> +		__u8	count;	/* count of active entries */
> +	} hdr;
> +	struct xfs_attr_sf_entry {
> +		__uint8_t namelen;	/* actual length of name (no NULL) */
> +		__uint8_t valuelen;	/* actual length of value (no NULL) */
> +		__uint8_t flags;	/* flags bits (see xfs_attr_leaf.h) */
> +		__uint8_t nameval[1];	/* name & value bytes concatenated */
> +	} list[1];			/* variable sized array */
> +} xfs_attr_shortform_t;
> +
>  typedef struct xfs_attr_leaf_map {	/* RLE map of free bytes */
>  	__be16	base;			  /* base of free region */
>  	__be16	size;			  /* length of free region */
> diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c
> index e1968b4..f40649e 100644
> --- a/libxfs/xfs_inode_fork.c
> +++ b/libxfs/xfs_inode_fork.c
> @@ -27,6 +27,7 @@
>  #include "xfs_bmap.h"
>  #include "xfs_trace.h"
>  #include "xfs_attr_sf.h"
> +#include "xfs_da_format.h"
>  
>  kmem_zone_t *xfs_ifork_zone;
>  
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 1/5] xfs_io: detect the '-R' option in getopt
  2016-01-23  4:55 ` [PATCH 1/5] xfs_io: detect the '-R' option in getopt Eric Sandeen
@ 2016-01-23  6:18   ` Darrick J. Wong
  2016-01-23 18:03     ` Eric Sandeen
  0 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-23  6:18 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Fri, Jan 22, 2016 at 10:55:52PM -0600, Eric Sandeen wrote:
> On 1/22/16 6:35 PM, Darrick J. Wong wrote:
> > Configure getopt to accept the -R argument to pwrite.
> 
> Did you have anything against "F" and "B"? :)
> 
> (They're missing too but in the case statements & help)

No, but I /was/ wondering if the omission was deliberate?

--D

> 
> -Eric
> 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  io/pwrite.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > 
> > diff --git a/io/pwrite.c b/io/pwrite.c
> > index fd9114d..c6efee9 100644
> > --- a/io/pwrite.c
> > +++ b/io/pwrite.c
> > @@ -259,7 +259,7 @@ pwrite_f(
> >  	init_cvtnum(&fsblocksize, &fssectsize);
> >  	bsize = fsblocksize;
> >  
> > -	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
> > +	while ((c = getopt(argc, argv, "b:Cdf:i:qRs:S:uV:wWZ:")) != EOF) {
> >  		switch (c) {
> >  		case 'b':
> >  			tmp = cvtnum(fsblocksize, fssectsize, optarg);
> > 
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
> > 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 1/5] xfs_io: detect the '-R' option in getopt
  2016-01-23  6:18   ` Darrick J. Wong
@ 2016-01-23 18:03     ` Eric Sandeen
  2016-01-26 22:09       ` Darrick J. Wong
  0 siblings, 1 reply; 23+ messages in thread
From: Eric Sandeen @ 2016-01-23 18:03 UTC (permalink / raw)
  To: xfs



On 1/23/16 12:18 AM, Darrick J. Wong wrote:
> On Fri, Jan 22, 2016 at 10:55:52PM -0600, Eric Sandeen wrote:
>> On 1/22/16 6:35 PM, Darrick J. Wong wrote:
>>> Configure getopt to accept the -R argument to pwrite.
>>
>> Did you have anything against "F" and "B"? :)
>>
>> (They're missing too but in the case statements & help)
> 
> No, but I /was/ wondering if the omission was deliberate?

I don't think so; the commit that added it (8fb2237)
seemed to do everything but add the getopt chars.

Oh, and however much gets fixed up, probably needs a man page
update too.

Thanks,
-Eric

> --D
> 
>>
>> -Eric
>>
>>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
>>> ---
>>>  io/pwrite.c |    2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>>
>>> diff --git a/io/pwrite.c b/io/pwrite.c
>>> index fd9114d..c6efee9 100644
>>> --- a/io/pwrite.c
>>> +++ b/io/pwrite.c
>>> @@ -259,7 +259,7 @@ pwrite_f(
>>>  	init_cvtnum(&fsblocksize, &fssectsize);
>>>  	bsize = fsblocksize;
>>>  
>>> -	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
>>> +	while ((c = getopt(argc, argv, "b:Cdf:i:qRs:S:uV:wWZ:")) != EOF) {
>>>  		switch (c) {
>>>  		case 'b':
>>>  			tmp = cvtnum(fsblocksize, fssectsize, optarg);
>>>
>>> _______________________________________________
>>> xfs mailing list
>>> xfs@oss.sgi.com
>>> http://oss.sgi.com/mailman/listinfo/xfs
>>>
>>
>> _______________________________________________
>> xfs mailing list
>> xfs@oss.sgi.com
>> http://oss.sgi.com/mailman/listinfo/xfs
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 1/5] xfs_io: detect the '-R' option in getopt
  2016-01-23 18:03     ` Eric Sandeen
@ 2016-01-26 22:09       ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-26 22:09 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Sat, Jan 23, 2016 at 12:03:00PM -0600, Eric Sandeen wrote:
> 
> 
> On 1/23/16 12:18 AM, Darrick J. Wong wrote:
> > On Fri, Jan 22, 2016 at 10:55:52PM -0600, Eric Sandeen wrote:
> >> On 1/22/16 6:35 PM, Darrick J. Wong wrote:
> >>> Configure getopt to accept the -R argument to pwrite.
> >>
> >> Did you have anything against "F" and "B"? :)
> >>
> >> (They're missing too but in the case statements & help)
> > 
> > No, but I /was/ wondering if the omission was deliberate?
> 
> I don't think so; the commit that added it (8fb2237)
> seemed to do everything but add the getopt chars.
> 
> Oh, and however much gets fixed up, probably needs a man page
> update too.

The manpage already has -F/-B/-R, but you're right that I should add
-F and -B to getopt.

--D

> 
> Thanks,
> -Eric
> 
> > --D
> > 
> >>
> >> -Eric
> >>
> >>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> >>> ---
> >>>  io/pwrite.c |    2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>>
> >>> diff --git a/io/pwrite.c b/io/pwrite.c
> >>> index fd9114d..c6efee9 100644
> >>> --- a/io/pwrite.c
> >>> +++ b/io/pwrite.c
> >>> @@ -259,7 +259,7 @@ pwrite_f(
> >>>  	init_cvtnum(&fsblocksize, &fssectsize);
> >>>  	bsize = fsblocksize;
> >>>  
> >>> -	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
> >>> +	while ((c = getopt(argc, argv, "b:Cdf:i:qRs:S:uV:wWZ:")) != EOF) {
> >>>  		switch (c) {
> >>>  		case 'b':
> >>>  			tmp = cvtnum(fsblocksize, fssectsize, optarg);
> >>>
> >>> _______________________________________________
> >>> xfs mailing list
> >>> xfs@oss.sgi.com
> >>> http://oss.sgi.com/mailman/listinfo/xfs
> >>>
> >>
> >> _______________________________________________
> >> xfs mailing list
> >> xfs@oss.sgi.com
> >> http://oss.sgi.com/mailman/listinfo/xfs
> > 
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
> > 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 1/5 v2] xfs_io: detect the '-R' option in getopt
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
                   ` (4 preceding siblings ...)
  2016-01-23  4:55 ` [PATCH 1/5] xfs_io: detect the '-R' option in getopt Eric Sandeen
@ 2016-01-27  0:58 ` Darrick J. Wong
  2016-01-27  4:30   ` Eric Sandeen
  2016-01-27  4:44 ` [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting Darrick J. Wong
  6 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-27  0:58 UTC (permalink / raw)
  To: david; +Cc: xfs

Configure getopt to accept the -R argument to pwrite.

v2: Accept -F and -B while we're at it.

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

diff --git a/io/pwrite.c b/io/pwrite.c
index fd9114d..4fc8de6 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -259,7 +259,7 @@ pwrite_f(
 	init_cvtnum(&fsblocksize, &fssectsize);
 	bsize = fsblocksize;
 
-	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
+	while ((c = getopt(argc, argv, "b:BCdf:Fi:qRs:S:uV:wWZ:")) != EOF) {
 		switch (c) {
 		case 'b':
 			tmp = cvtnum(fsblocksize, fssectsize, optarg);

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 1/5 v2] xfs_io: detect the '-R' option in getopt
  2016-01-27  0:58 ` [PATCH 1/5 v2] " Darrick J. Wong
@ 2016-01-27  4:30   ` Eric Sandeen
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Sandeen @ 2016-01-27  4:30 UTC (permalink / raw)
  To: xfs

Rockin!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

On 1/26/16 6:58 PM, Darrick J. Wong wrote:
> Configure getopt to accept the -R argument to pwrite.
> 
> v2: Accept -F and -B while we're at it.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  io/pwrite.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/io/pwrite.c b/io/pwrite.c
> index fd9114d..4fc8de6 100644
> --- a/io/pwrite.c
> +++ b/io/pwrite.c
> @@ -259,7 +259,7 @@ pwrite_f(
>  	init_cvtnum(&fsblocksize, &fssectsize);
>  	bsize = fsblocksize;
>  
> -	while ((c = getopt(argc, argv, "b:Cdf:i:qs:S:uV:wWZ:")) != EOF) {
> +	while ((c = getopt(argc, argv, "b:BCdf:Fi:qRs:S:uV:wWZ:")) != EOF) {
>  		switch (c) {
>  		case 'b':
>  			tmp = cvtnum(fsblocksize, fssectsize, optarg);
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting
  2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
                   ` (5 preceding siblings ...)
  2016-01-27  0:58 ` [PATCH 1/5 v2] " Darrick J. Wong
@ 2016-01-27  4:44 ` Darrick J. Wong
  2016-02-01 15:18   ` Brian Foster
  6 siblings, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-01-27  4:44 UTC (permalink / raw)
  To: david; +Cc: xfs

Since the finobt affects the size of the log reservations, we need to
be able to include its effects in the calculation of the minimum log
size.

(Not really a problem now, but adding rmapbt will give this one some
bite.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 mkfs/maxtrres.c |    5 ++++-
 mkfs/xfs_mkfs.c |    2 +-
 mkfs/xfs_mkfs.h |    2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mkfs/maxtrres.c b/mkfs/maxtrres.c
index e1d5ee9..b97d020 100644
--- a/mkfs/maxtrres.c
+++ b/mkfs/maxtrres.c
@@ -36,7 +36,8 @@ max_trans_res(
 	int		inodelog,
 	int		dirblocklog,
 	int		logversion,
-	int		log_sunit)
+	int		log_sunit,
+	int		finobt)
 {
 	xfs_sb_t	*sbp;
 	xfs_mount_t	mount;
@@ -68,6 +69,8 @@ max_trans_res(
 			(dirversion == 2 ? XFS_SB_VERSION_DIRV2BIT : 0) |
 			(logversion > 1 ? XFS_SB_VERSION_LOGV2BIT : 0) |
 			XFS_DFL_SB_VERSION_BITS;
+	if (finobt)
+		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_FINOBT;
 
 	libxfs_mount(&mount, sbp, 0,0,0,0);
 	maxfsb = xfs_log_calc_minimum_size(&mount);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 700d12c..4c3a802 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2406,7 +2406,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 
 	min_logblocks = max_trans_res(crcs_enabled, dirversion,
 				   sectorlog, blocklog, inodelog, dirblocklog,
-				   logversion, lsunit);
+				   logversion, lsunit, finobt);
 	ASSERT(min_logblocks);
 	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
 	if (!logsize && dblocks >= (1024*1024*1024) >> blocklog)
diff --git a/mkfs/xfs_mkfs.h b/mkfs/xfs_mkfs.h
index 9df5f37..128068e 100644
--- a/mkfs/xfs_mkfs.h
+++ b/mkfs/xfs_mkfs.h
@@ -84,6 +84,6 @@ extern void res_failed (int err);
 /* maxtrres.c */
 extern int max_trans_res (int crcs_enabled, int dirversion,
 		int sectorlog, int blocklog, int inodelog, int dirblocklog,
-		int logversion, int log_sunit);
+		int logversion, int log_sunit, int finobt);
 
 #endif	/* __XFS_MKFS_H__ */

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
@ 2016-02-01 15:17   ` Brian Foster
  2016-02-01 19:14     ` Darrick J. Wong
  2016-02-11 23:48   ` Darrick J. Wong
  1 sibling, 1 reply; 23+ messages in thread
From: Brian Foster @ 2016-02-01 15:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Fri, Jan 22, 2016 at 04:35:08PM -0800, Darrick J. Wong wrote:
> Create a macro to generate btree height calculator functions.
> This will be used (much) later when we get to the refcount
> btree.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

The refactoring looks fine to me... though shouldn't this head into the
kernel first and get backported to xfsprogs (or did I miss that
somewhere)?

That and one question below...

>  libxfs/xfs_bmap.c       |   18 +-----------------
>  libxfs/xfs_bmap_btree.c |    9 +++++++++
>  libxfs/xfs_bmap_btree.h |    3 +++
>  libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
>  libxfs/xfs_btree.h      |    3 +++
>  5 files changed, 44 insertions(+), 17 deletions(-)
> 
> 
> diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> index aef7cf3..c134765 100644
> --- a/libxfs/xfs_bmap.c
> +++ b/libxfs/xfs_bmap.c
> @@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
>  	xfs_inode_t	*ip,		/* incore inode pointer */
>  	xfs_filblks_t	len)		/* delayed extent length */
>  {
> -	int		level;		/* btree level number */
> -	int		maxrecs;	/* maximum record count at this level */
> -	xfs_mount_t	*mp;		/* mount structure */
>  	xfs_filblks_t	rval;		/* return value */
>  
> -	mp = ip->i_mount;
> -	maxrecs = mp->m_bmap_dmxr[0];
> -	for (level = 0, rval = 0;
> -	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
> -	     level++) {
> -		len += maxrecs - 1;
> -		do_div(len, maxrecs);
> -		rval += len;
> -		if (len == 1)
> -			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
> -				level - 1;
> -		if (level == 0)
> -			maxrecs = mp->m_bmap_dmxr[1];
> -	}
> +	rval = xfs_bmbt_calc_size(ip->i_mount, len);

We go from xfs_filblks_t to unsigned long here. Isn't the latter 4 bytes
on 32-bit systems? Was that intentional?

Brian

>  	return rval;
>  }
>  
> diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c
> index 2ef1836..3c595e2 100644
> --- a/libxfs/xfs_bmap_btree.c
> +++ b/libxfs/xfs_bmap_btree.c
> @@ -880,3 +880,12 @@ xfs_bmbt_change_owner(
>  	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
>  	return error;
>  }
> +
> +xfs_filblks_t
> +xfs_bmbt_calc_size(
> +	struct xfs_mount	*mp,
> +	unsigned long		len)
> +{
> +	return xfs_btree_calc_size(mp, mp->m_bmap_dmxr,
> +			XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), len);
> +}
> diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h
> index 819a8a4..04bc6e2 100644
> --- a/libxfs/xfs_bmap_btree.h
> +++ b/libxfs/xfs_bmap_btree.h
> @@ -140,4 +140,7 @@ extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
>  extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
>  		struct xfs_trans *, struct xfs_inode *, int);
>  
> +extern xfs_filblks_t xfs_bmbt_calc_size(struct xfs_mount *mp,
> +		unsigned long len);
> +
>  #endif	/* __XFS_BMAP_BTREE_H__ */
> diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
> index 658f27e..d5f16c5 100644
> --- a/libxfs/xfs_btree.c
> +++ b/libxfs/xfs_btree.c
> @@ -4081,6 +4081,34 @@ xfs_btree_change_owner(
>  	return 0;
>  }
>  
> +/*
> + * xfs_btree_calc_size() -- Calculate the number of blocks needed to store
> + *			    a given number of records.
> + */
> +xfs_filblks_t
> +xfs_btree_calc_size(
> +	struct xfs_mount	*mp,
> +	uint			*limits,
> +	int			maxlevels,
> +	unsigned long		len)
> +{
> +	int			level;
> +	int			maxrecs;
> +	xfs_filblks_t		rval;
> +
> +	maxrecs = limits[0];
> +	for (level = 0, rval = 0; level < maxlevels; level++) {
> +		len += maxrecs - 1;
> +		do_div(len, maxrecs);
> +		rval += len;
> +		if (len == 1)
> +			return rval + maxlevels - level - 1;
> +		if (level == 0)
> +			maxrecs = limits[1];
> +	}
> +	return rval;
> +}
> +
>  /**
>   * xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
>   *				      btree block
> diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h
> index 48cb251..b25ffd3 100644
> --- a/libxfs/xfs_btree.h
> +++ b/libxfs/xfs_btree.h
> @@ -465,6 +465,9 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
>  #define XFS_BTREE_TRACE_ARGR(c, r)
>  #define	XFS_BTREE_TRACE_CURSOR(c, t)
>  
> +xfs_filblks_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits,
> +		int maxlevels, unsigned long len);
> +
>  bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
>  bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
>  
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize
  2016-01-23  0:35 ` [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize Darrick J. Wong
@ 2016-02-01 15:18   ` Brian Foster
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Foster @ 2016-02-01 15:18 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Fri, Jan 22, 2016 at 04:35:25PM -0800, Darrick J. Wong wrote:
> When the block size is large enough that multiple inode chunks can fit
> in a single block (e.g. 64k blocks, 512 byte inodes) we must calculate
> the per-chunk block size and the buffer offset correctly so that check
> actually examines the correct metadata.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  db/check.c |   13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/db/check.c b/db/check.c
> index 838db53..4e2768e 100644
> --- a/db/check.c
> +++ b/db/check.c
> @@ -4386,6 +4386,7 @@ scanfunc_ino(
>  	__u16			holemask;
>  	xfs_agino_t		rino;
>  	xfs_extlen_t		cblocks;
> +	int			bufoff;
>  
>  	if (be32_to_cpu(block->bb_magic) != XFS_IBT_MAGIC &&
>  	    be32_to_cpu(block->bb_magic) != XFS_IBT_CRC_MAGIC) {
> @@ -4455,6 +4456,8 @@ scanfunc_ino(
>  				rino = agino + startidx;
>  				cblocks = (endidx - startidx) >>
>  						mp->m_sb.sb_inopblog;
> +				if (cblocks == 0)
> +					cblocks = 1;

A comment would be nice here (i.e., "handle the case where the entire
chunk is in a single block").

>  
>  				/* Check the sparse chunk alignment */
>  				if (sparse &&
> @@ -4468,8 +4471,9 @@ scanfunc_ino(
>  				}
>  
>  				/* Check the block map */
> -				set_dbmap(seqno, XFS_AGINO_TO_AGBNO(mp, rino),
> -					cblocks, DBM_INODE, seqno, bno);
> +				if (XFS_AGINO_TO_OFFSET(mp, rino) == 0)
> +					set_dbmap(seqno, XFS_AGINO_TO_AGBNO(mp, rino),
> +						cblocks, DBM_INODE, seqno, bno);
>  
>  				push_cur();
>  				set_cur(&typtab[TYP_INODE],
> @@ -4489,14 +4493,15 @@ scanfunc_ino(
>  				}
>  
>  				/* Examine each inode in this chunk */
> -				for (j = startidx; j < endidx; j++) {
> +				bufoff = ((XFS_AGINO_TO_OFFSET(mp, rino) - startidx) << mp->m_sb.sb_inodelog);
> +				for (j = startidx; j < endidx; j++, bufoff += (1 << mp->m_sb.sb_inodelog)) {

Here as well.

Though, does this work for sparse inodes? Suppose we start halfway into
a sparse inode record. So XFS_AGINO_TO_OFFSET(mp, rino) is 0 since we're
at the first inode of the fs block; and say startidx is 32 as that could
be the first real inode index in the record. It looks like we could go
off the rails in that case..?

Brian

>  					if (ino_issparse(&rp[i], j))
>  						continue;
>  					isfree = XFS_INOBT_IS_FREE_DISK(&rp[i], j);
>  					if (isfree)
>  						nfree++;
>  					process_inode(agf, agino + j,
> -						(xfs_dinode_t *)((char *)iocur_top->data + ((j - startidx) << mp->m_sb.sb_inodelog)),
> +						(xfs_dinode_t *)((char *)iocur_top->data + bufoff),
>  							isfree);
>  				}
>  				pop_cur();
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting
  2016-01-27  4:44 ` [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting Darrick J. Wong
@ 2016-02-01 15:18   ` Brian Foster
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Foster @ 2016-02-01 15:18 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Tue, Jan 26, 2016 at 08:44:48PM -0800, Darrick J. Wong wrote:
> Since the finobt affects the size of the log reservations, we need to
> be able to include its effects in the calculation of the minimum log
> size.
> 
> (Not really a problem now, but adding rmapbt will give this one some
> bite.)
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  mkfs/maxtrres.c |    5 ++++-
>  mkfs/xfs_mkfs.c |    2 +-
>  mkfs/xfs_mkfs.h |    2 +-
>  3 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/mkfs/maxtrres.c b/mkfs/maxtrres.c
> index e1d5ee9..b97d020 100644
> --- a/mkfs/maxtrres.c
> +++ b/mkfs/maxtrres.c
> @@ -36,7 +36,8 @@ max_trans_res(
>  	int		inodelog,
>  	int		dirblocklog,
>  	int		logversion,
> -	int		log_sunit)
> +	int		log_sunit,
> +	int		finobt)
>  {
>  	xfs_sb_t	*sbp;
>  	xfs_mount_t	mount;
> @@ -68,6 +69,8 @@ max_trans_res(
>  			(dirversion == 2 ? XFS_SB_VERSION_DIRV2BIT : 0) |
>  			(logversion > 1 ? XFS_SB_VERSION_LOGV2BIT : 0) |
>  			XFS_DFL_SB_VERSION_BITS;
> +	if (finobt)
> +		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_FINOBT;
>  
>  	libxfs_mount(&mount, sbp, 0,0,0,0);
>  	maxfsb = xfs_log_calc_minimum_size(&mount);
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 700d12c..4c3a802 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2406,7 +2406,7 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
>  
>  	min_logblocks = max_trans_res(crcs_enabled, dirversion,
>  				   sectorlog, blocklog, inodelog, dirblocklog,
> -				   logversion, lsunit);
> +				   logversion, lsunit, finobt);
>  	ASSERT(min_logblocks);
>  	min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
>  	if (!logsize && dblocks >= (1024*1024*1024) >> blocklog)
> diff --git a/mkfs/xfs_mkfs.h b/mkfs/xfs_mkfs.h
> index 9df5f37..128068e 100644
> --- a/mkfs/xfs_mkfs.h
> +++ b/mkfs/xfs_mkfs.h
> @@ -84,6 +84,6 @@ extern void res_failed (int err);
>  /* maxtrres.c */
>  extern int max_trans_res (int crcs_enabled, int dirversion,
>  		int sectorlog, int blocklog, int inodelog, int dirblocklog,
> -		int logversion, int log_sunit);
> +		int logversion, int log_sunit, int finobt);
>  
>  #endif	/* __XFS_MKFS_H__ */
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-02-01 15:17   ` Brian Foster
@ 2016-02-01 19:14     ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-02-01 19:14 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Mon, Feb 01, 2016 at 10:17:56AM -0500, Brian Foster wrote:
> On Fri, Jan 22, 2016 at 04:35:08PM -0800, Darrick J. Wong wrote:
> > Create a macro to generate btree height calculator functions.
> > This will be used (much) later when we get to the refcount
> > btree.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> 
> The refactoring looks fine to me... though shouldn't this head into the
> kernel first and get backported to xfsprogs (or did I miss that
> somewhere)?

I think I've posted the kernelside version of this patch, though I suppose it
doesn't really become important until one starts adding the rmap/reflink stuff.

> That and one question below...
> 
> >  libxfs/xfs_bmap.c       |   18 +-----------------
> >  libxfs/xfs_bmap_btree.c |    9 +++++++++
> >  libxfs/xfs_bmap_btree.h |    3 +++
> >  libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
> >  libxfs/xfs_btree.h      |    3 +++
> >  5 files changed, 44 insertions(+), 17 deletions(-)
> > 
> > 
> > diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> > index aef7cf3..c134765 100644
> > --- a/libxfs/xfs_bmap.c
> > +++ b/libxfs/xfs_bmap.c
> > @@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
> >  	xfs_inode_t	*ip,		/* incore inode pointer */
> >  	xfs_filblks_t	len)		/* delayed extent length */
> >  {
> > -	int		level;		/* btree level number */
> > -	int		maxrecs;	/* maximum record count at this level */
> > -	xfs_mount_t	*mp;		/* mount structure */
> >  	xfs_filblks_t	rval;		/* return value */
> >  
> > -	mp = ip->i_mount;
> > -	maxrecs = mp->m_bmap_dmxr[0];
> > -	for (level = 0, rval = 0;
> > -	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
> > -	     level++) {
> > -		len += maxrecs - 1;
> > -		do_div(len, maxrecs);
> > -		rval += len;
> > -		if (len == 1)
> > -			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
> > -				level - 1;
> > -		if (level == 0)
> > -			maxrecs = mp->m_bmap_dmxr[1];
> > -	}
> > +	rval = xfs_bmbt_calc_size(ip->i_mount, len);
> 
> We go from xfs_filblks_t to unsigned long here. Isn't the latter 4 bytes
> on 32-bit systems? Was that intentional?

Semi-intentional.  The 'len' argument is the number of records you want to
store in the btree.  For a bmbt, we're capped by di_nextents/di_anextents,
which limit us to 2^32 records and I think the methods in xfs_bmap.c won't
create an extent longer than MAXEXTLEN (2^21) blocks anyway.

OTOH I suppose the rmap btree can store more than 2^32 records when reflink
is turned on (not that you'd want to) so this could be widened to ULL.

--D

> 
> Brian
> 
> >  	return rval;
> >  }
> >  
> > diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c
> > index 2ef1836..3c595e2 100644
> > --- a/libxfs/xfs_bmap_btree.c
> > +++ b/libxfs/xfs_bmap_btree.c
> > @@ -880,3 +880,12 @@ xfs_bmbt_change_owner(
> >  	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
> >  	return error;
> >  }
> > +
> > +xfs_filblks_t
> > +xfs_bmbt_calc_size(
> > +	struct xfs_mount	*mp,
> > +	unsigned long		len)
> > +{
> > +	return xfs_btree_calc_size(mp, mp->m_bmap_dmxr,
> > +			XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), len);
> > +}
> > diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h
> > index 819a8a4..04bc6e2 100644
> > --- a/libxfs/xfs_bmap_btree.h
> > +++ b/libxfs/xfs_bmap_btree.h
> > @@ -140,4 +140,7 @@ extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
> >  extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
> >  		struct xfs_trans *, struct xfs_inode *, int);
> >  
> > +extern xfs_filblks_t xfs_bmbt_calc_size(struct xfs_mount *mp,
> > +		unsigned long len);
> > +
> >  #endif	/* __XFS_BMAP_BTREE_H__ */
> > diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
> > index 658f27e..d5f16c5 100644
> > --- a/libxfs/xfs_btree.c
> > +++ b/libxfs/xfs_btree.c
> > @@ -4081,6 +4081,34 @@ xfs_btree_change_owner(
> >  	return 0;
> >  }
> >  
> > +/*
> > + * xfs_btree_calc_size() -- Calculate the number of blocks needed to store
> > + *			    a given number of records.
> > + */
> > +xfs_filblks_t
> > +xfs_btree_calc_size(
> > +	struct xfs_mount	*mp,
> > +	uint			*limits,
> > +	int			maxlevels,
> > +	unsigned long		len)
> > +{
> > +	int			level;
> > +	int			maxrecs;
> > +	xfs_filblks_t		rval;
> > +
> > +	maxrecs = limits[0];
> > +	for (level = 0, rval = 0; level < maxlevels; level++) {
> > +		len += maxrecs - 1;
> > +		do_div(len, maxrecs);
> > +		rval += len;
> > +		if (len == 1)
> > +			return rval + maxlevels - level - 1;
> > +		if (level == 0)
> > +			maxrecs = limits[1];
> > +	}
> > +	return rval;
> > +}
> > +
> >  /**
> >   * xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
> >   *				      btree block
> > diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h
> > index 48cb251..b25ffd3 100644
> > --- a/libxfs/xfs_btree.h
> > +++ b/libxfs/xfs_btree.h
> > @@ -465,6 +465,9 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
> >  #define XFS_BTREE_TRACE_ARGR(c, r)
> >  #define	XFS_BTREE_TRACE_CURSOR(c, t)
> >  
> > +xfs_filblks_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits,
> > +		int maxlevels, unsigned long len);
> > +
> >  bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
> >  bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
> >  
> > 
> > _______________________________________________
> > xfs mailing list
> > xfs@oss.sgi.com
> > http://oss.sgi.com/mailman/listinfo/xfs
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout
  2016-01-23  0:35 ` [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout Darrick J. Wong
@ 2016-02-02  5:14   ` Dave Chinner
  2016-02-02  5:16     ` Darrick J. Wong
  2016-02-02  5:16     ` Dave Chinner
  0 siblings, 2 replies; 23+ messages in thread
From: Dave Chinner @ 2016-02-02  5:14 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Fri, Jan 22, 2016 at 04:35:31PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  io/reflink.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/io/reflink.c b/io/reflink.c
> index def01be..a09e82d 100644
> --- a/io/reflink.c
> +++ b/io/reflink.c
> @@ -78,11 +78,13 @@ dedupe_ioctl(
>  			goto done;
>  		}
>  		if (info->status < 0) {
> -			printf("dedupe: %s\n", _(strerror(-info->status)));
> +			fprintf(stderr, "dedupe: %s\n",
> +					_(strerror(-info->status)));
>  			goto done;
>  		}
>  		if (info->status == XFS_EXTENT_DATA_DIFFERS) {
> -			printf(_("Extents did not match.\n"));
> +			fprintf(stderr, "dedupe: %s\n",
> +					_("Extents did not match."));
>  			goto done;
>  		}
>  		if (args->length != 0 &&

I think this patch breaks dedupe detection in xfstests. I see the
dedupe tests running instead of being detected as not supported, and
all the diffs from test failures contain:

    +dedupe: Invalid argument

This is on 4.5-rc2, so I suspect it's not returning the expected
"not supported" error to xfstests from the ioctl.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout
  2016-02-02  5:14   ` Dave Chinner
@ 2016-02-02  5:16     ` Darrick J. Wong
  2016-02-02  5:16     ` Dave Chinner
  1 sibling, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-02-02  5:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Tue, Feb 02, 2016 at 04:14:10PM +1100, Dave Chinner wrote:
> On Fri, Jan 22, 2016 at 04:35:31PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  io/reflink.c |    6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/io/reflink.c b/io/reflink.c
> > index def01be..a09e82d 100644
> > --- a/io/reflink.c
> > +++ b/io/reflink.c
> > @@ -78,11 +78,13 @@ dedupe_ioctl(
> >  			goto done;
> >  		}
> >  		if (info->status < 0) {
> > -			printf("dedupe: %s\n", _(strerror(-info->status)));
> > +			fprintf(stderr, "dedupe: %s\n",
> > +					_(strerror(-info->status)));
> >  			goto done;
> >  		}
> >  		if (info->status == XFS_EXTENT_DATA_DIFFERS) {
> > -			printf(_("Extents did not match.\n"));
> > +			fprintf(stderr, "dedupe: %s\n",
> > +					_("Extents did not match."));
> >  			goto done;
> >  		}
> >  		if (args->length != 0 &&
> 
> I think this patch breaks dedupe detection in xfstests. I see the
> dedupe tests running instead of being detected as not supported, and
> all the diffs from test failures contain:
> 
>     +dedupe: Invalid argument
> 
> This is on 4.5-rc2, so I suspect it's not returning the expected
> "not supported" error to xfstests from the ioctl.

Christoph sent a patch "[PATCH 3/4] xfstests: also treat EINVAL as
reflink/dedup not supported" to take care of that.

--D

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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout
  2016-02-02  5:14   ` Dave Chinner
  2016-02-02  5:16     ` Darrick J. Wong
@ 2016-02-02  5:16     ` Dave Chinner
  1 sibling, 0 replies; 23+ messages in thread
From: Dave Chinner @ 2016-02-02  5:16 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Tue, Feb 02, 2016 at 04:14:10PM +1100, Dave Chinner wrote:
> On Fri, Jan 22, 2016 at 04:35:31PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  io/reflink.c |    6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/io/reflink.c b/io/reflink.c
> > index def01be..a09e82d 100644
> > --- a/io/reflink.c
> > +++ b/io/reflink.c
> > @@ -78,11 +78,13 @@ dedupe_ioctl(
> >  			goto done;
> >  		}
> >  		if (info->status < 0) {
> > -			printf("dedupe: %s\n", _(strerror(-info->status)));
> > +			fprintf(stderr, "dedupe: %s\n",
> > +					_(strerror(-info->status)));
> >  			goto done;
> >  		}
> >  		if (info->status == XFS_EXTENT_DATA_DIFFERS) {
> > -			printf(_("Extents did not match.\n"));
> > +			fprintf(stderr, "dedupe: %s\n",
> > +					_("Extents did not match."));
> >  			goto done;
> >  		}
> >  		if (args->length != 0 &&
> 
> I think this patch breaks dedupe detection in xfstests. I see the
> dedupe tests running instead of being detected as not supported, and
> all the diffs from test failures contain:
> 
>     +dedupe: Invalid argument
> 
> This is on 4.5-rc2, so I suspect it's not returning the expected
> "not supported" error to xfstests from the ioctl.

Oh, never mind. I just found the xfstests patches Christoph sent to
the wrong list that will fix this.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
  2016-02-01 15:17   ` Brian Foster
@ 2016-02-11 23:48   ` Darrick J. Wong
  2016-02-12  1:07     ` Dave Chinner
  1 sibling, 1 reply; 23+ messages in thread
From: Darrick J. Wong @ 2016-02-11 23:48 UTC (permalink / raw)
  To: david; +Cc: xfs

On Fri, Jan 22, 2016 at 04:35:08PM -0800, Darrick J. Wong wrote:
> Create a macro to generate btree height calculator functions.
> This will be used (much) later when we get to the refcount
> btree.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  libxfs/xfs_bmap.c       |   18 +-----------------
>  libxfs/xfs_bmap_btree.c |    9 +++++++++
>  libxfs/xfs_bmap_btree.h |    3 +++
>  libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
>  libxfs/xfs_btree.h      |    3 +++
>  5 files changed, 44 insertions(+), 17 deletions(-)
> 
> 
> diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> index aef7cf3..c134765 100644
> --- a/libxfs/xfs_bmap.c
> +++ b/libxfs/xfs_bmap.c
> @@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
>  	xfs_inode_t	*ip,		/* incore inode pointer */
>  	xfs_filblks_t	len)		/* delayed extent length */
>  {
> -	int		level;		/* btree level number */
> -	int		maxrecs;	/* maximum record count at this level */
> -	xfs_mount_t	*mp;		/* mount structure */
>  	xfs_filblks_t	rval;		/* return value */
>  
> -	mp = ip->i_mount;
> -	maxrecs = mp->m_bmap_dmxr[0];
> -	for (level = 0, rval = 0;
> -	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
> -	     level++) {
> -		len += maxrecs - 1;
> -		do_div(len, maxrecs);
> -		rval += len;
> -		if (len == 1)
> -			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
> -				level - 1;
> -		if (level == 0)
> -			maxrecs = mp->m_bmap_dmxr[1];
> -	}
> +	rval = xfs_bmbt_calc_size(ip->i_mount, len);

NAK.  This function figures out how many blocks could be required to handle
adding (worst-case one-extent-per-block) extents to the bmbt and btree splits
all the way up the tree, whereas xfs_btree_calc_size() merely calculates the
number of blocks needed to create a tree with some number of records.  When I
start using the AG reservation code and counting the number of blocks in use at
mount time, using the below xfs_btree_calc_size() to calculate the resevation
size leads to undersized reservations, which (I think?) explains why I still
occasionally run out of blocks when expanding the refcount tree, which is
supposed to reserve /all/ the blocks it'll ever need.

This function should go back to the way it was, and the xfs_btree_calc_size()
function will get fixed to calculate tree size correctly.

Also NAK on the kernelside version of this patch.

--D

>  	return rval;
>  }
>  
> diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c
> index 2ef1836..3c595e2 100644
> --- a/libxfs/xfs_bmap_btree.c
> +++ b/libxfs/xfs_bmap_btree.c
> @@ -880,3 +880,12 @@ xfs_bmbt_change_owner(
>  	xfs_btree_del_cursor(cur, error ? XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
>  	return error;
>  }
> +
> +xfs_filblks_t
> +xfs_bmbt_calc_size(
> +	struct xfs_mount	*mp,
> +	unsigned long		len)
> +{
> +	return xfs_btree_calc_size(mp, mp->m_bmap_dmxr,
> +			XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), len);
> +}
> diff --git a/libxfs/xfs_bmap_btree.h b/libxfs/xfs_bmap_btree.h
> index 819a8a4..04bc6e2 100644
> --- a/libxfs/xfs_bmap_btree.h
> +++ b/libxfs/xfs_bmap_btree.h
> @@ -140,4 +140,7 @@ extern int xfs_bmbt_change_owner(struct xfs_trans *tp, struct xfs_inode *ip,
>  extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
>  		struct xfs_trans *, struct xfs_inode *, int);
>  
> +extern xfs_filblks_t xfs_bmbt_calc_size(struct xfs_mount *mp,
> +		unsigned long len);
> +
>  #endif	/* __XFS_BMAP_BTREE_H__ */
> diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c
> index 658f27e..d5f16c5 100644
> --- a/libxfs/xfs_btree.c
> +++ b/libxfs/xfs_btree.c
> @@ -4081,6 +4081,34 @@ xfs_btree_change_owner(
>  	return 0;
>  }
>  
> +/*
> + * xfs_btree_calc_size() -- Calculate the number of blocks needed to store
> + *			    a given number of records.
> + */
> +xfs_filblks_t
> +xfs_btree_calc_size(
> +	struct xfs_mount	*mp,
> +	uint			*limits,
> +	int			maxlevels,
> +	unsigned long		len)
> +{
> +	int			level;
> +	int			maxrecs;
> +	xfs_filblks_t		rval;
> +
> +	maxrecs = limits[0];
> +	for (level = 0, rval = 0; level < maxlevels; level++) {
> +		len += maxrecs - 1;
> +		do_div(len, maxrecs);
> +		rval += len;
> +		if (len == 1)
> +			return rval + maxlevels - level - 1;
> +		if (level == 0)
> +			maxrecs = limits[1];
> +	}
> +	return rval;
> +}
> +
>  /**
>   * xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
>   *				      btree block
> diff --git a/libxfs/xfs_btree.h b/libxfs/xfs_btree.h
> index 48cb251..b25ffd3 100644
> --- a/libxfs/xfs_btree.h
> +++ b/libxfs/xfs_btree.h
> @@ -465,6 +465,9 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
>  #define XFS_BTREE_TRACE_ARGR(c, r)
>  #define	XFS_BTREE_TRACE_CURSOR(c, t)
>  
> +xfs_filblks_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits,
> +		int maxlevels, unsigned long len);
> +
>  bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
>  bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
>  
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-02-11 23:48   ` Darrick J. Wong
@ 2016-02-12  1:07     ` Dave Chinner
  2016-02-12  1:24       ` Darrick J. Wong
  0 siblings, 1 reply; 23+ messages in thread
From: Dave Chinner @ 2016-02-12  1:07 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Thu, Feb 11, 2016 at 03:48:07PM -0800, Darrick J. Wong wrote:
> On Fri, Jan 22, 2016 at 04:35:08PM -0800, Darrick J. Wong wrote:
> > Create a macro to generate btree height calculator functions.
> > This will be used (much) later when we get to the refcount
> > btree.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  libxfs/xfs_bmap.c       |   18 +-----------------
> >  libxfs/xfs_bmap_btree.c |    9 +++++++++
> >  libxfs/xfs_bmap_btree.h |    3 +++
> >  libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
> >  libxfs/xfs_btree.h      |    3 +++
> >  5 files changed, 44 insertions(+), 17 deletions(-)
> > 
> > 
> > diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> > index aef7cf3..c134765 100644
> > --- a/libxfs/xfs_bmap.c
> > +++ b/libxfs/xfs_bmap.c
> > @@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
> >  	xfs_inode_t	*ip,		/* incore inode pointer */
> >  	xfs_filblks_t	len)		/* delayed extent length */
> >  {
> > -	int		level;		/* btree level number */
> > -	int		maxrecs;	/* maximum record count at this level */
> > -	xfs_mount_t	*mp;		/* mount structure */
> >  	xfs_filblks_t	rval;		/* return value */
> >  
> > -	mp = ip->i_mount;
> > -	maxrecs = mp->m_bmap_dmxr[0];
> > -	for (level = 0, rval = 0;
> > -	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
> > -	     level++) {
> > -		len += maxrecs - 1;
> > -		do_div(len, maxrecs);
> > -		rval += len;
> > -		if (len == 1)
> > -			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
> > -				level - 1;
> > -		if (level == 0)
> > -			maxrecs = mp->m_bmap_dmxr[1];
> > -	}
> > +	rval = xfs_bmbt_calc_size(ip->i_mount, len);
> 
> NAK.  This function figures out how many blocks could be required to handle
> adding (worst-case one-extent-per-block) extents to the bmbt and btree splits
> all the way up the tree, whereas xfs_btree_calc_size() merely calculates the
> number of blocks needed to create a tree with some number of records.  When I
> start using the AG reservation code and counting the number of blocks in use at
> mount time, using the below xfs_btree_calc_size() to calculate the resevation
> size leads to undersized reservations, which (I think?) explains why I still
> occasionally run out of blocks when expanding the refcount tree, which is
> supposed to reserve /all/ the blocks it'll ever need.
> 
> This function should go back to the way it was, and the xfs_btree_calc_size()
> function will get fixed to calculate tree size correctly.
> 
> Also NAK on the kernelside version of this patch.

Thanks for the heads-up, Darrick. I hadn't pulled this in to either
tree yet, because it hadn't got a reviewed-by. I guess that's a sign
that the process is working as it should. :P

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH 2/5] libxfs: refactor the btree size calculator code
  2016-02-12  1:07     ` Dave Chinner
@ 2016-02-12  1:24       ` Darrick J. Wong
  0 siblings, 0 replies; 23+ messages in thread
From: Darrick J. Wong @ 2016-02-12  1:24 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

On Fri, Feb 12, 2016 at 12:07:22PM +1100, Dave Chinner wrote:
> On Thu, Feb 11, 2016 at 03:48:07PM -0800, Darrick J. Wong wrote:
> > On Fri, Jan 22, 2016 at 04:35:08PM -0800, Darrick J. Wong wrote:
> > > Create a macro to generate btree height calculator functions.
> > > This will be used (much) later when we get to the refcount
> > > btree.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  libxfs/xfs_bmap.c       |   18 +-----------------
> > >  libxfs/xfs_bmap_btree.c |    9 +++++++++
> > >  libxfs/xfs_bmap_btree.h |    3 +++
> > >  libxfs/xfs_btree.c      |   28 ++++++++++++++++++++++++++++
> > >  libxfs/xfs_btree.h      |    3 +++
> > >  5 files changed, 44 insertions(+), 17 deletions(-)
> > > 
> > > 
> > > diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
> > > index aef7cf3..c134765 100644
> > > --- a/libxfs/xfs_bmap.c
> > > +++ b/libxfs/xfs_bmap.c
> > > @@ -172,25 +172,9 @@ xfs_bmap_worst_indlen(
> > >  	xfs_inode_t	*ip,		/* incore inode pointer */
> > >  	xfs_filblks_t	len)		/* delayed extent length */
> > >  {
> > > -	int		level;		/* btree level number */
> > > -	int		maxrecs;	/* maximum record count at this level */
> > > -	xfs_mount_t	*mp;		/* mount structure */
> > >  	xfs_filblks_t	rval;		/* return value */
> > >  
> > > -	mp = ip->i_mount;
> > > -	maxrecs = mp->m_bmap_dmxr[0];
> > > -	for (level = 0, rval = 0;
> > > -	     level < XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK);
> > > -	     level++) {
> > > -		len += maxrecs - 1;
> > > -		do_div(len, maxrecs);
> > > -		rval += len;
> > > -		if (len == 1)
> > > -			return rval + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) -
> > > -				level - 1;
> > > -		if (level == 0)
> > > -			maxrecs = mp->m_bmap_dmxr[1];
> > > -	}
> > > +	rval = xfs_bmbt_calc_size(ip->i_mount, len);
> > 
> > NAK.  This function figures out how many blocks could be required to handle
> > adding (worst-case one-extent-per-block) extents to the bmbt and btree splits
> > all the way up the tree, whereas xfs_btree_calc_size() merely calculates the
> > number of blocks needed to create a tree with some number of records.  When I
> > start using the AG reservation code and counting the number of blocks in use at
> > mount time, using the below xfs_btree_calc_size() to calculate the resevation
> > size leads to undersized reservations, which (I think?) explains why I still
> > occasionally run out of blocks when expanding the refcount tree, which is
> > supposed to reserve /all/ the blocks it'll ever need.
> > 
> > This function should go back to the way it was, and the xfs_btree_calc_size()
> > function will get fixed to calculate tree size correctly.
> > 
> > Also NAK on the kernelside version of this patch.
> 
> Thanks for the heads-up, Darrick. I hadn't pulled this in to either
> tree yet, because it hadn't got a reviewed-by. I guess that's a sign
> that the process is working as it should. :P

lol. :)

I'll post a branch off of your for-next 4.6 branch soon; it'll have all
the fixes that have been accumulating since the last RFC posting.

--D

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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2016-02-12  1:24 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23  0:35 [PATCH 1/5] xfs_io: detect the '-R' option in getopt Darrick J. Wong
2016-01-23  0:35 ` [PATCH 2/5] libxfs: refactor the btree size calculator code Darrick J. Wong
2016-02-01 15:17   ` Brian Foster
2016-02-01 19:14     ` Darrick J. Wong
2016-02-11 23:48   ` Darrick J. Wong
2016-02-12  1:07     ` Dave Chinner
2016-02-12  1:24       ` Darrick J. Wong
2016-01-23  0:35 ` [PATCH 3/5] libxfs: move struct xfs_attr_shortform to xfs_da_format.h Darrick J. Wong
2016-01-23  5:08   ` Eric Sandeen
2016-01-23  0:35 ` [PATCH 4/5] xfs_db: don't error out when blocksize > 64 * inodesize Darrick J. Wong
2016-02-01 15:18   ` Brian Foster
2016-01-23  0:35 ` [PATCH 5/5] xfs_io: print dedupe errors to stderr, not stdout Darrick J. Wong
2016-02-02  5:14   ` Dave Chinner
2016-02-02  5:16     ` Darrick J. Wong
2016-02-02  5:16     ` Dave Chinner
2016-01-23  4:55 ` [PATCH 1/5] xfs_io: detect the '-R' option in getopt Eric Sandeen
2016-01-23  6:18   ` Darrick J. Wong
2016-01-23 18:03     ` Eric Sandeen
2016-01-26 22:09       ` Darrick J. Wong
2016-01-27  0:58 ` [PATCH 1/5 v2] " Darrick J. Wong
2016-01-27  4:30   ` Eric Sandeen
2016-01-27  4:44 ` [PATCH 6/5] mkfs: factor finobt changes into min log size when formatting Darrick J. Wong
2016-02-01 15:18   ` Brian Foster

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.