linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: fix userdata allocation detection regression
@ 2019-09-20  2:19 Christoph Hellwig
  2019-09-23 12:48 ` Brian Foster
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2019-09-20  2:19 UTC (permalink / raw)
  To: linux-xfs; +Cc: kernel test robot

The XFS_ALLOC_USERDATA was not directly used, but indirectly in the
xfs_alloc_is_userdata function that check for any bit that is not
XFS_ALLOC_NOBUSY being set.  But XFS_ALLOC_NOBUSY is equivalent to
a user data allocation, so rename that flag and check for that instead
to reduce the confusion.

Fixes: 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_alloc.h | 7 ++++---
 fs/xfs/libxfs/xfs_bmap.c  | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index 58fa85cec325..24710746cecb 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -83,18 +83,19 @@ typedef struct xfs_alloc_arg {
  */
 #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 << 2)/* allocation is for user data*/
 
 static inline bool
 xfs_alloc_is_userdata(int datatype)
 {
-	return (datatype & ~XFS_ALLOC_NOBUSY) != 0;
+	return (datatype & XFS_ALLOC_USERDATA);
 }
 
 static inline bool
 xfs_alloc_allow_busy_reuse(int datatype)
 {
-	return (datatype & XFS_ALLOC_NOBUSY) == 0;
+	/* Busy extents not allowed for user data */
+	return (datatype & XFS_ALLOC_USERDATA) == 0;
 }
 
 /* freespace limit calculations */
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 054b4ce30033..a2d8c4e4cad5 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4041,7 +4041,7 @@ xfs_bmapi_allocate(
 	 * the busy list.
 	 */
 	if (!(bma->flags & XFS_BMAPI_METADATA)) {
-		bma->datatype = XFS_ALLOC_NOBUSY;
+		bma->datatype = XFS_ALLOC_USERDATA;
 		if (whichfork == XFS_DATA_FORK && bma->offset == 0)
 			bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
 		if (bma->flags & XFS_BMAPI_ZERO)
-- 
2.20.1


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

* Re: [PATCH] xfs: fix userdata allocation detection regression
  2019-09-20  2:19 [PATCH] xfs: fix userdata allocation detection regression Christoph Hellwig
@ 2019-09-23 12:48 ` Brian Foster
  2019-09-23 19:09   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Foster @ 2019-09-23 12:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Thu, Sep 19, 2019 at 07:19:43PM -0700, Christoph Hellwig wrote:
> The XFS_ALLOC_USERDATA was not directly used, but indirectly in the
> xfs_alloc_is_userdata function that check for any bit that is not
> XFS_ALLOC_NOBUSY being set.  But XFS_ALLOC_NOBUSY is equivalent to
> a user data allocation, so rename that flag and check for that instead
> to reduce the confusion.
> 
> Fixes: 1baa2800e62d ("xfs: remove the unused XFS_ALLOC_USERDATA flag")
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_alloc.h | 7 ++++---
>  fs/xfs/libxfs/xfs_bmap.c  | 2 +-
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
> index 58fa85cec325..24710746cecb 100644
> --- a/fs/xfs/libxfs/xfs_alloc.h
> +++ b/fs/xfs/libxfs/xfs_alloc.h
> @@ -83,18 +83,19 @@ typedef struct xfs_alloc_arg {
>   */
>  #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 << 2)/* allocation is for user data*/
>  
>  static inline bool
>  xfs_alloc_is_userdata(int datatype)
>  {
> -	return (datatype & ~XFS_ALLOC_NOBUSY) != 0;
> +	return (datatype & XFS_ALLOC_USERDATA);
>  }
>  

Prior to this change (and commit 1baa2800e62d), something like an xattr
remote value block would not be considered user data. As of this change,
that is no longer the case. That seems reasonable on first thought (it
is user data after all), but I'm not so sure it's appropriate once you
look through some of the ways xfs_alloc_is_userdata() is used.

Brian

>  static inline bool
>  xfs_alloc_allow_busy_reuse(int datatype)
>  {
> -	return (datatype & XFS_ALLOC_NOBUSY) == 0;
> +	/* Busy extents not allowed for user data */
> +	return (datatype & XFS_ALLOC_USERDATA) == 0;
>  }
>  
>  /* freespace limit calculations */
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 054b4ce30033..a2d8c4e4cad5 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4041,7 +4041,7 @@ xfs_bmapi_allocate(
>  	 * the busy list.
>  	 */
>  	if (!(bma->flags & XFS_BMAPI_METADATA)) {
> -		bma->datatype = XFS_ALLOC_NOBUSY;
> +		bma->datatype = XFS_ALLOC_USERDATA;
>  		if (whichfork == XFS_DATA_FORK && bma->offset == 0)
>  			bma->datatype |= XFS_ALLOC_INITIAL_USER_DATA;
>  		if (bma->flags & XFS_BMAPI_ZERO)
> -- 
> 2.20.1
> 

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

* Re: [PATCH] xfs: fix userdata allocation detection regression
  2019-09-23 12:48 ` Brian Foster
@ 2019-09-23 19:09   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-09-23 19:09 UTC (permalink / raw)
  To: Brian Foster; +Cc: Christoph Hellwig, linux-xfs

On Mon, Sep 23, 2019 at 08:48:36AM -0400, Brian Foster wrote:
> Prior to this change (and commit 1baa2800e62d), something like an xattr
> remote value block would not be considered user data. As of this change,
> that is no longer the case. That seems reasonable on first thought (it
> is user data after all), but I'm not so sure it's appropriate once you
> look through some of the ways xfs_alloc_is_userdata() is used.

True.  Let's just revert the original patch for now, and sort out the
mess of these flags properly later.

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

end of thread, other threads:[~2019-09-23 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20  2:19 [PATCH] xfs: fix userdata allocation detection regression Christoph Hellwig
2019-09-23 12:48 ` Brian Foster
2019-09-23 19:09   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).