Skip to contentSkip to conversation

xfs: revert 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")

PATCH In review Darrick J. Wong 4 participants 4 messages Sep 23, 2019 – Dec 4, 2019 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: revert 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")

From: Darrick J. Wong <[email protected]>

Revert this commit, as it caused periodic regressions in xfs/173 w/ 1k blocks[1].

[1] https://lore.kernel.org/lkml/20190919014602.GN15734@shao2-debian/

---
 fs/xfs/libxfs/xfs_alloc.h |    7 ++++---
 fs/xfs/libxfs/xfs_bmap.c  |    8 ++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_alloc.h +4 -3
index 58fa85cec325..d6ed5d2c07c2 100644
@@ -81,9 +81,10 @@ typedef struct xfs_alloc_arg {
 /*
  * Defines for datatype
  */
-#define XFS_ALLOC_INITIAL_USER_DATA	(1 << 0)/* special case start of file */
-#define XFS_ALLOC_USERDATA_ZERO		(1 << 1)/* zero extent on allocation */
-#define XFS_ALLOC_NOBUSY		(1 << 2)/* Busy extents not allowed */
+#define XFS_ALLOC_USERDATA		(1 << 0)/* allocation is for user data*/
+#define XFS_ALLOC_INITIAL_USER_DATA	(1 << 1)/* special case start of file */
+#define XFS_ALLOC_USERDATA_ZERO		(1 << 2)/* zero extent on allocation */
+#define XFS_ALLOC_NOBUSY		(1 << 3)/* Busy extents not allowed */
 
 static inline bool
 xfs_alloc_is_userdata(int datatype)
fs/xfs/libxfs/xfs_bmap.c +6 -2
index eaf2d4250a26..4edc25a2ba80 100644
@@ -4042,8 +4042,12 @@ xfs_bmapi_allocate(
 	 */
 	if (!(bma->flags & XFS_BMAPI_METADATA)) {
 		bma->datatype = XFS_ALLOC_NOBUSY;
-		if (whichfork == XFS_DATA_FORK && bma->offset == 0)
-			bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
+		if (whichfork == XFS_DATA_FORK) {
+			if (bma->offset == 0)
+				bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
+			else
+				bma->datatype |= XFS_ALLOC_USERDATA;
+		}
 		if (bma->flags & XFS_BMAPI_ZERO)
 			bma->datatype |= XFS_ALLOC_USERDATA_ZERO;
 	}
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Revert this commit, as it caused periodic regressions in xfs/173 w/ 1k blocks[1].

[1] https://lore.kernel.org/lkml/20190919014602.GN15734@shao2-debian/

---

Quoted 41 lines
 fs/xfs/libxfs/xfs_alloc.h |    7 ++++---
 fs/xfs/libxfs/xfs_bmap.c  |    8 ++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_alloc.h +4 -3
index 58fa85cec325..d6ed5d2c07c2 100644
@@ -81,9 +81,10 @@ typedef struct xfs_alloc_arg {
 /*
  * Defines for datatype
  */
-#define XFS_ALLOC_INITIAL_USER_DATA	(1 << 0)/* special case start of file */
-#define XFS_ALLOC_USERDATA_ZERO		(1 << 1)/* zero extent on allocation */
-#define XFS_ALLOC_NOBUSY		(1 << 2)/* Busy extents not allowed */
+#define XFS_ALLOC_USERDATA		(1 << 0)/* allocation is for user data*/
+#define XFS_ALLOC_INITIAL_USER_DATA	(1 << 1)/* special case start of file */
+#define XFS_ALLOC_USERDATA_ZERO		(1 << 2)/* zero extent on allocation */
+#define XFS_ALLOC_NOBUSY		(1 << 3)/* Busy extents not allowed */
 
 static inline bool
 xfs_alloc_is_userdata(int datatype)
fs/xfs/libxfs/xfs_bmap.c +6 -2
index eaf2d4250a26..4edc25a2ba80 100644
@@ -4042,8 +4042,12 @@ xfs_bmapi_allocate(
 	 */
 	if (!(bma->flags & XFS_BMAPI_METADATA)) {
 		bma->datatype = XFS_ALLOC_NOBUSY;
-		if (whichfork == XFS_DATA_FORK && bma->offset == 0)
-			bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
+		if (whichfork == XFS_DATA_FORK) {
+			if (bma->offset == 0)
+				bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
+			else
+				bma->datatype |= XFS_ALLOC_USERDATA;
+		}
 		if (bma->flags & XFS_BMAPI_ZERO)
 			bma->datatype |= XFS_ALLOC_USERDATA_ZERO;
 	}
#3 lore raw
In reply to Darrick J. Wong
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Revert this commit, as it caused periodic regressions in xfs/173 w/ 1k blocks[1].

[1] https://lore.kernel.org/lkml/20190919014602.GN15734@shao2-debian/

Came across this randomly ... since there's no explanation in the changelog as to /why/ this broke things, I think it's due to:

static inline bool
xfs_alloc_is_userdata(int datatype)

{
        return (datatype & ~XFS_ALLOC_NOBUSY) != 0;
}

which would previously have returned true if (datatype & XFS_ALLOC_USERDATA), but without the any flag set returned false. So failing to set XFS_ALLOC_USERDATA indirectly changed the result of this test.

So, you're welcome, future code archaeologists. :)

-Eric