Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1672046 > unrolled thread

[PATCH 18/32] ext4: retry storing value in external inode with xattr block too

Started byTahsin Erdogan <tahsin@google.com>
First post2017-06-21 23:30 +0200
Last post2017-06-22 04:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 18/32] ext4: retry storing value in external inode with xattr block too Tahsin Erdogan <tahsin@google.com> - 2017-06-21 23:30 +0200
    Re: [PATCH 18/32] ext4: retry storing value in external inode with  xattr block too Theodore Ts'o <tytso@mit.edu> - 2017-06-22 04:30 +0200

#1672046 — [PATCH 18/32] ext4: retry storing value in external inode with xattr block too

FromTahsin Erdogan <tahsin@google.com>
Date2017-06-21 23:30 +0200
Subject[PATCH 18/32] ext4: retry storing value in external inode with xattr block too
Message-ID<tUVmi-3od-17@gated-at.bofh.it>
When value size is <= EXT4_XATTR_MIN_LARGE_EA_SIZE(), and it
doesn't fit in either inline or xattr block, a second try is made to
store it in an external inode while storing the entry itself in inline
area. There should also be an attempt to store the entry in xattr block.

This patch adds a retry loop to do that. It also makes the caller the
sole decider on whether to store a value in an external inode.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
v2: fix checkpatch.pl warning about indented retry_inode: label

 fs/ext4/xattr.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index dcf7ec98f138..0dfae3f8e209 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -911,11 +911,6 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
 	int in_inode = i->in_inode;
 	int rc;
 
-	if (ext4_has_feature_ea_inode(inode->i_sb) &&
-	    (EXT4_XATTR_SIZE(i->value_len) >
-	     EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
-		in_inode = 1;
-
 	/* Compute min_offs and last. */
 	last = s->first;
 	for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
@@ -1097,7 +1092,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
 {
 	struct super_block *sb = inode->i_sb;
 	struct buffer_head *new_bh = NULL;
-	struct ext4_xattr_search *s = &bs->s;
+	struct ext4_xattr_search s_copy = bs->s;
+	struct ext4_xattr_search *s = &s_copy;
 	struct mb_cache_entry *ce = NULL;
 	int error = 0;
 	struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
@@ -1519,6 +1515,11 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 		if (!bs.s.not_found && ext4_xattr_value_same(&bs.s, &i))
 			goto cleanup;
 
+		if (ext4_has_feature_ea_inode(inode->i_sb) &&
+		    (EXT4_XATTR_SIZE(i.value_len) >
+			EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
+			i.in_inode = 1;
+retry_inode:
 		error = ext4_xattr_ibody_set(handle, inode, &i, &is);
 		if (!error && !bs.s.not_found) {
 			i.value = NULL;
@@ -1530,20 +1531,20 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 					goto cleanup;
 			}
 			error = ext4_xattr_block_set(handle, inode, &i, &bs);
-			if (ext4_has_feature_ea_inode(inode->i_sb) &&
-			    error == -ENOSPC) {
-				/* xattr not fit to block, store at external
-				 * inode */
-				i.in_inode = 1;
-				error = ext4_xattr_ibody_set(handle, inode,
-							     &i, &is);
-			}
-			if (error)
-				goto cleanup;
-			if (!is.s.not_found) {
+			if (!error && !is.s.not_found) {
 				i.value = NULL;
 				error = ext4_xattr_ibody_set(handle, inode, &i,
 							     &is);
+			} else if (error == -ENOSPC) {
+				/*
+				 * Xattr does not fit in the block, store at
+				 * external inode if possible.
+				 */
+				if (ext4_has_feature_ea_inode(inode->i_sb) &&
+				    !i.in_inode) {
+					i.in_inode = 1;
+					goto retry_inode;
+				}
 			}
 		}
 	}
-- 
2.13.1.611.g7e3b11ae1-goog

[toc] | [next] | [standalone]


#1672256 — Re: [PATCH 18/32] ext4: retry storing value in external inode with xattr block too

FromTheodore Ts'o <tytso@mit.edu>
Date2017-06-22 04:30 +0200
SubjectRe: [PATCH 18/32] ext4: retry storing value in external inode with xattr block too
Message-ID<tV02C-6I7-1@gated-at.bofh.it>
In reply to#1672046
On Wed, Jun 21, 2017 at 02:21:28PM -0700, Tahsin Erdogan wrote:
> When value size is <= EXT4_XATTR_MIN_LARGE_EA_SIZE(), and it
> doesn't fit in either inline or xattr block, a second try is made to
> store it in an external inode while storing the entry itself in inline
> area. There should also be an attempt to store the entry in xattr block.
> 
> This patch adds a retry loop to do that. It also makes the caller the
> sole decider on whether to store a value in an external inode.
> 
> Signed-off-by: Tahsin Erdogan <tahsin@google.com>

Thanks, added to the ext4 patch queue.

						- Ted

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web