From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ipmail05.adl6.internode.on.net ([150.101.137.143]:44229 "EHLO ipmail05.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750730AbcGFECa (ORCPT ); Wed, 6 Jul 2016 00:02:30 -0400 Date: Wed, 6 Jul 2016 14:01:20 +1000 From: Dave Chinner To: "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, vishal.l.verma@intel.com, xfs@oss.sgi.com, Dave Chinner Subject: Re: [PATCH 026/119] xfs: add owner field to extent allocation and freeing Message-ID: <20160706040120.GA12670@dastard> References: <146612627129.12839.3827886950949809165.stgit@birch.djwong.org> <146612643914.12839.17925699349002137545.stgit@birch.djwong.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <146612643914.12839.17925699349002137545.stgit@birch.djwong.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Jun 16, 2016 at 06:20:39PM -0700, Darrick J. Wong wrote: > For the rmap btree to work, we have to feed the extent owner > information to the the allocation and freeing functions. This > information is what will end up in the rmap btree that tracks > allocated extents. While we technically don't need the owner > information when freeing extents, passing it allows us to validate > that the extent we are removing from the rmap btree actually > belonged to the owner we expected it to belong to. .... > --- a/fs/xfs/libxfs/xfs_format.h > +++ b/fs/xfs/libxfs/xfs_format.h > @@ -1318,6 +1318,71 @@ typedef __be32 xfs_inobt_ptr_t; > */ > #define XFS_RMAP_CRC_MAGIC 0x524d4233 /* 'RMB3' */ > > +/* > + * Ownership info for an extent. This is used to create reverse-mapping > + * entries. > + */ > +#define XFS_OWNER_INFO_ATTR_FORK (1 << 0) > +#define XFS_OWNER_INFO_BMBT_BLOCK (1 << 1) > +struct xfs_owner_info { > + uint64_t oi_owner; > + xfs_fileoff_t oi_offset; > + unsigned int oi_flags; > +}; > + > +static inline void > +xfs_rmap_ag_owner( > + struct xfs_owner_info *oi, > + uint64_t owner) > +{ > + oi->oi_owner = owner; > + oi->oi_offset = 0; > + oi->oi_flags = 0; > +} > + > +static inline void > +xfs_rmap_ino_bmbt_owner( > + struct xfs_owner_info *oi, > + xfs_ino_t ino, > + int whichfork) > +{ > + oi->oi_owner = ino; > + oi->oi_offset = 0; > + oi->oi_flags = XFS_OWNER_INFO_BMBT_BLOCK; > + if (whichfork == XFS_ATTR_FORK) > + oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; > +} > + > +static inline void > +xfs_rmap_ino_owner( > + struct xfs_owner_info *oi, > + xfs_ino_t ino, > + int whichfork, > + xfs_fileoff_t offset) > +{ > + oi->oi_owner = ino; > + oi->oi_offset = offset; > + oi->oi_flags = 0; > + if (whichfork == XFS_ATTR_FORK) > + oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; > +} One of the things we've avaoided doing so far is putting functions like this into xfs_format.h. xfs_format.h is really just for the on disk format definitions, not the code to access/pack/unpack it. Hence I think think these sorts of functions need to be moved to xfs_rmap.h.... Cheers, Dave. -- Dave Chinner david@fromorbit.com