Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1672235 > unrolled thread
| Started by | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| First post | 2017-06-22 04:00 +0200 |
| Last post | 2017-06-22 18:00 +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.
[PATCH 29/32] ext4: reserve space for xattr entries/names Tahsin Erdogan <tahsin@google.com> - 2017-06-22 04:00 +0200
Re: [PATCH 29/32] ext4: reserve space for xattr entries/names Theodore Ts'o <tytso@mit.edu> - 2017-06-22 18:00 +0200
| From | Tahsin Erdogan <tahsin@google.com> |
|---|---|
| Date | 2017-06-22 04:00 +0200 |
| Subject | [PATCH 29/32] ext4: reserve space for xattr entries/names |
| Message-ID | <tUZzz-6c3-3@gated-at.bofh.it> |
New ea_inode feature allows putting large xattr values into external
inodes. struct ext4_xattr_entry and the attribute name however have to
remain in the inode extra space or external attribute block. Once that
space is exhausted, no further entries can be added. Some of that space
could also be used by values that fit in there at the time of addition.
So, a single xattr entry whose value barely fits in the external block
could prevent further entries being added.
To mitigate the problem, this patch introduces a notion of reserve in
the
external attribute block that cannot be used by value data. This reserve
is enforced when ea_inode feature is enabled. The amount of reserve is
arbitrarily chosen to be min(block_size/8, 1024). The table below shows
how much space is reserved for each block size and the guaranteed
mininum
number of entries that can be placed in the external attribute block.
block size reserved bytes entries (name length = 16)
1k 128 3
2k 256 7
4k 512 15
8k 1024 31
16k 1024 31
32k 1024 31
64k 1024 31
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
fs/ext4/xattr.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index a3f8bf4558f3..835b3dca5b65 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1446,6 +1446,12 @@ static int ext4_xattr_inode_lookup_create(handle_t *handle, struct inode *inode,
return 0;
}
+/*
+ * Reserve min(block_size/8, 1024) bytes for xattr entries/names if ea_inode
+ * feature is enabled.
+ */
+#define EXT4_XATTR_BLOCK_RESERVE(inode) min(i_blocksize(inode)/8, 1024U)
+
static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
struct ext4_xattr_search *s,
handle_t *handle, struct inode *inode)
@@ -1505,6 +1511,20 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
ret = -ENOSPC;
goto out;
}
+
+ /*
+ * If storing the value in an external inode is an option,
+ * reserve space for xattr entries/names in the external
+ * attribute block so that a long value does not occupy the
+ * whole space and prevent futher entries being added.
+ */
+ if (ext4_has_feature_ea_inode(inode->i_sb) && new_size &&
+ (s->end - s->base) == i_blocksize(inode) &&
+ (min_offs + old_size - new_size) <
+ EXT4_XATTR_BLOCK_RESERVE(inode)) {
+ ret = -ENOSPC;
+ goto out;
+ }
}
/*
--
2.13.1.611.g7e3b11ae1-goog
[toc] | [next] | [standalone]
| From | Theodore Ts'o <tytso@mit.edu> |
|---|---|
| Date | 2017-06-22 18:00 +0200 |
| Message-ID | <tVcGu-6LO-25@gated-at.bofh.it> |
| In reply to | #1672235 |
On Wed, Jun 21, 2017 at 06:49:36PM -0700, Tahsin Erdogan wrote: > New ea_inode feature allows putting large xattr values into external > inodes. struct ext4_xattr_entry and the attribute name however have to > remain in the inode extra space or external attribute block. Once that > space is exhausted, no further entries can be added. Some of that space > could also be used by values that fit in there at the time of addition. > > So, a single xattr entry whose value barely fits in the external block > could prevent further entries being added. > > To mitigate the problem, this patch introduces a notion of reserve in > the > external attribute block that cannot be used by value data. This reserve > is enforced when ea_inode feature is enabled. The amount of reserve is > arbitrarily chosen to be min(block_size/8, 1024). The table below shows > how much space is reserved for each block size and the guaranteed > mininum > number of entries that can be placed in the external attribute block. > > block size reserved bytes entries (name length = 16) > 1k 128 3 > 2k 256 7 > 4k 512 15 > 8k 1024 31 > 16k 1024 31 > 32k 1024 31 > 64k 1024 31 > > Signed-off-by: Tahsin Erdogan <tahsin@google.com> Thanks, applied. - Ted
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web