All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tiger Yang <tiger.yang@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 07/15] ocfs2: reserve inline space for extended attribute v2
Date: Fri, 11 Jul 2008 16:55:55 +0800	[thread overview]
Message-ID: <4877201B.6090400@oracle.com> (raw)
In-Reply-To: <20080710012456.GM28100@wotan.suse.de>

hi, Mark,
Thank you for your patient and your very detailed explanation.
I am very clear about this now.

Best regards,
tiger

Mark Fasheh wrote:
> Thanks for breaking this patch up even smaller.
> 
> On Fri, Jun 27, 2008 at 03:27:34PM +0800, Tiger Yang wrote:
>> This patch reserve some space in inode block for extended attribute.
>> That space used to store extent list or inline data.
>>
>> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
>> ---
>>  fs/ocfs2/alloc.c    |   31 +++++++++++++++++++++++--------
>>  fs/ocfs2/ocfs2.h    |    3 +++
>>  fs/ocfs2/ocfs2_fs.h |   36 ++++++++++++++++++++++++++++++++++--
>>  fs/ocfs2/super.c    |    2 ++
>>  4 files changed, 62 insertions(+), 10 deletions(-)
>>
>> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
>> index 3a06271..2df5a7f 100644
>> --- a/fs/ocfs2/alloc.c
>> +++ b/fs/ocfs2/alloc.c
>> @@ -6417,26 +6417,40 @@ out:
>>  	return ret;
>>  }
>>  
>> -static void ocfs2_zero_dinode_id2(struct inode *inode, struct ocfs2_dinode *di)
>> +static void ocfs2_zero_dinode_id2_with_xattr(struct super_block *sb,
>> +					     struct ocfs2_dinode *di,
>> +					     int xattrsize)
>>  {
>> -	unsigned int blocksize = 1 << inode->i_sb->s_blocksize_bits;
>> -
>> -	memset(&di->id2, 0, blocksize - offsetof(struct ocfs2_dinode, id2));
>> +	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
>> +		memset(&di->id2, 0, sb->s_blocksize -
>> +				    offsetof(struct ocfs2_dinode, id2) -
>> +				    xattrsize);
>> +	else
>> +		memset(&di->id2, 0, sb->s_blocksize -
>> +				    offsetof(struct ocfs2_dinode, id2));
>>  }
> 
> Wasn't the plan to also store inline xattr size on the inode, when it has
> OCFS2_INLINE_XATTR_FL set and only use s_xattr_inline_size when figuring out
> if a non-inline-xattr inode has enough space?
> 
> struct ocfs2_dinode {
> 	...
> 	__u16 i_xattr_inline_size;
> 	...
> };
> 
> 
> This way ocfs2_zero_dinode_id2_with_xattr becomes:
> 
> static void ocfs2_zero_dinode_id2_with_xattr(struct super_block *sb,
> 					     struct ocfs2_dinode *di)
> {
> 	unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
> 
> 	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
> 		memset(&di->id2, 0, sb->s_blocksize -
> 				    offsetof(struct ocfs2_dinode, id2) -
> 				    xattrsize);
> 	else
> 		memset(&di->id2, 0, sb->s_blocksize -
> 				    offsetof(struct ocfs2_dinode, id2));
> }
> 
> 
> Think of this in terms of l_count on the in-inode extent list. We could have
> just stored that on the superblock, because lets face it - l_count hasn't
> changed for a particular block size, ever. But if we did that, then making
> space for inline xattrs wouldn't be as simple as just shrinking l_count
> because tons of code which iterates the extent list would assume "oh, every
> inode has exactly this many inline extents" instead of just _looking at the
> inode_ to see how many inline extents it contains. And really, I think it's
> just good practice to have our structures be self-referencial.
> 
> It's not enough to just change ocfs2_zero_dinode_id2_with_xattr() by the way
> - you need to get this correct for all functions which take inline xattr
> size into account. Luckily, your code is written well enough that this
> shouldn't be a big deal.
> 
> 
> Functions like ocfs2_xattr_has_space_inline() change too, but in a slightly
> different way. Those functions deal an inode that does _not_ have inline
> xattrs, but instead try to figure out whether they'll fit. In those cases,
> you use s_xattr_inline_size as a guideline:
> 
> 
> static int ocfs2_xattr_has_space_inline(struct inode *inode,
> 					struct ocfs2_dinode *di)
> {
> 	struct ocfs2_inode_info *oi = OCFS2_I(inode);
> 	int xattrsize = OCFS2_SB(inode->i_sb)->s_xattr_inline_size;
> 	int free;
> 
> 	if (xattrsize < OCFS2_MIN_XATTR_INLINE_SIZE)
> 		return 0;
> 
> 	if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
> 		struct ocfs2_inline_data *idata = &di->id2.i_data;
> 		free = le16_to_cpu(idata->id_count) - le64_to_cpu(di->i_size);
> 	} else {
> 		struct ocfs2_extent_list *el = &di->id2.i_list;
> 		free = (le16_to_cpu(el->l_count) -
> 			le16_to_cpu(el->l_next_free_rec)) *
> 			sizeof(struct ocfs2_extent_rec);
> 	}
> 	if (free >= xattrsize)
> 		return 1;
> 
> 	return 0;
> }
> 
> 
> And then, of course when you're *setting* inline xattrs for the first time
> (generally, this just means "when you set the INLINE_XATTR_FL"), you need to
> populate i_xattr_inline_size with something meaningful. I _think_ this
> happens in ocfs2_xattr_set_entry() - I haven't gotten to that patch yet:
> 
> 
> 	if (!(oi->ip_dyn_features & OCFS2_INLINE_XATTR_FL) &&
> 	    (flag & OCFS2_INLINE_XATTR_FL)) {
> 		/*
> 		 * Adjust extent record count or inline data size
> 		 * to reserve space for extended attribute.
> 		 */
> 		if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
> 			struct ocfs2_inline_data *idata = &di->id2.i_data;
> 			le16_add_cpu(&idata->id_count, -xattrsize);
> 		} else {
> 			struct ocfs2_extent_list *el = &di->id2.i_list;
> 			le16_add_cpu(&el->l_count, -(xattrsize /
> 				     sizeof(struct ocfs2_extent_rec)));
> 		}
> 		di->i_xattr_inline_size = cpu_to_le16(osb->s_xattr_inline_size);
> 	}
> 
> 
> The test you should use, to figure out what some code should do is ask
> yourself "will this break, if the admin changes xattr_inline_size on a
> NON-empty file system?" If the answer is "no, i_xattr_inline_size on an
> inode with OCFS2_INLINE_XATTR_FL set is independent of the current value of
> s_xattr_inline_size" then you got it correct.
> 
> Let me know if any of this is unclear!
> 	--Mark
> 
> 
> --
> Mark Fasheh

      reply	other threads:[~2008-07-11  8:55 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27  6:39 [Ocfs2-devel] [PATCH 0/15] ocfs2: Add extended attributes for ocfs2. V2 Tao Ma
2008-06-27  6:59 ` [Ocfs2-devel] [PATCH 01/15] Modify ocfs2_num_free_extents for future xattr usage. v2 Tao Ma
2008-06-27  7:00 ` [Ocfs2-devel] [PATCH 02/15] Use ocfs2_extent_list instead of ocfs2_dinode. v2 Tao Ma
2008-06-27  7:00 ` [Ocfs2-devel] [PATCH 03/15] Abstract ocfs2_extent_tree in b-tree operations. v2 Tao Ma
2008-06-27  7:00 ` [Ocfs2-devel] [PATCH 04/15] Make extend allocation generic.v2 Tao Ma
2008-06-27  7:01 ` [Ocfs2-devel] [PATCH 05/15] Add xattr header in ocfs2.v2 Tao Ma
2008-07-09 22:59   ` Mark Fasheh
2008-07-10  4:50     ` Tao Ma
2008-07-17  0:30   ` Mark Fasheh
2008-07-19  0:44   ` Joel Becker
2008-06-27  7:01 ` [Ocfs2-devel] [PATCH 06/15] Add extent tree operation for xattr value.v2 Tao Ma
2008-07-09 23:10   ` Mark Fasheh
2008-07-10  4:30     ` Tao Ma
2008-06-27  7:01 ` [Ocfs2-devel] [PATCH 09/15] Add helper function in uptodate for removing xattr clusters.v2 Tao Ma
2008-07-10 23:15   ` Mark Fasheh
2008-07-10 23:19   ` Mark Fasheh
2008-06-27  7:02 ` [Ocfs2-devel] [PATCH 10/15] Add xattr tree operations in ocfs2_extent_tree.v2 Tao Ma
2008-06-27  7:02 ` [Ocfs2-devel] [PATCH 11/15] Add xattr bucket iteration for large numbers of EAs.v2 Tao Ma
2008-07-11 20:32   ` Mark Fasheh
2008-07-11 23:52     ` Tao Ma
2008-07-11 23:58       ` Mark Fasheh
2008-06-27  7:02 ` [Ocfs2-devel] [PATCH 12/15] Add xattr find process for xattr index btree.v2 Tao Ma
2008-07-11 23:59   ` Mark Fasheh
2008-07-12  0:42     ` Tao Ma
2008-07-18  0:47       ` Mark Fasheh
2008-06-27  7:02 ` [Ocfs2-devel] [PATCH 13/15] Enable xattr set in " Tao Ma
2008-07-18  0:30   ` Mark Fasheh
2008-06-27  7:03 ` [Ocfs2-devel] [PATCH 14/15] Delete all xattr buckets in inode removal.v2 Tao Ma
2008-06-27  7:27 ` [Ocfs2-devel] [PATCH 07/15] ocfs2: reserve inline space for extended attribute v2 Tiger Yang
2008-06-27  7:27   ` [Ocfs2-devel] [PATCH 08/15] ocfs2: Add extended attribute support v2 Tiger Yang
2008-06-27  7:27     ` [Ocfs2-devel] [PATCH 15/15] ocfs2: Add incompatible flag for extended attribute v2 Tiger Yang
2008-07-10 23:00       ` Mark Fasheh
2008-07-10 23:22         ` Joel Becker
2008-07-10 23:34           ` Mark Fasheh
2008-07-16  3:06           ` Tiger Yang
2008-07-16 17:39             ` Joel Becker
2008-07-10 23:11     ` [Ocfs2-devel] [PATCH 08/15] ocfs2: Add extended attribute support v2 Mark Fasheh
2008-07-11  2:21       ` tristan
2008-07-11  9:39         ` Tiger Yang
2008-07-17  9:34       ` Tiger Yang
2008-07-17 18:13         ` Mark Fasheh
2008-07-25  9:10       ` Tiger Yang
2008-07-11 19:47     ` Mark Fasheh
2008-07-17  9:39       ` Tiger Yang
2008-07-17 18:11         ` Mark Fasheh
2008-07-15 21:28     ` Mark Fasheh
2008-07-10  1:24   ` [Ocfs2-devel] [PATCH 07/15] ocfs2: reserve inline space for extended attribute v2 Mark Fasheh
2008-07-11  8:55     ` Tiger Yang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4877201B.6090400@oracle.com \
    --to=tiger.yang@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.