* Re: [PATCH v2 4/5] erofs: use meta buffers for xattr operations
@ 2022-01-11 0:26 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-01-11 0:26 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 23720 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220102040017.51352-5-hsiangkao@linux.alibaba.com>
References: <20220102040017.51352-5-hsiangkao@linux.alibaba.com>
TO: Gao Xiang <hsiangkao@linux.alibaba.com>
Hi Gao,
I love your patch! Perhaps something to improve:
[auto build test WARNING on xiang-erofs/dev-test]
[cannot apply to v5.16 next-20220110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gao-Xiang/erofs-get-rid-of-erofs_get_meta_page/20220102-120057
base: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: i386-randconfig-c001-20220105 (https://download.01.org/0day-ci/archive/20220111/202201110814.WDpkZzWX-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d5b6e30ed3acad794dd0aec400e617daffc6cc3d)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d7c5cceeea80de5a2a1b177d4952b9802a97edc0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gao-Xiang/erofs-get-rid-of-erofs_get_meta_page/20220102-120057
git checkout d7c5cceeea80de5a2a1b177d4952b9802a97edc0
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
mm/page_alloc.c:8373:2: note: Loop condition is true. Entering loop body
for_each_zone(zone) {
^
include/linux/mmzone.h:1122:2: note: expanded from macro 'for_each_zone'
for (zone = (first_online_pgdat())->node_zones; \
^
mm/page_alloc.c:8376:3: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&zone->lock, flags);
^
include/linux/spinlock.h:379:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:240:2: note: expanded from macro 'raw_spin_lock_irqsave'
do { \
^
mm/page_alloc.c:8376:3: note: Loop condition is false. Exiting loop
spin_lock_irqsave(&zone->lock, flags);
^
include/linux/spinlock.h:377:43: note: expanded from macro 'spin_lock_irqsave'
#define spin_lock_irqsave(lock, flags) \
^
mm/page_alloc.c:8378:3: note: The value 0 is assigned to '__base'
do_div(tmp, lowmem_pages);
^
arch/x86/include/asm/div64.h:25:2: note: expanded from macro 'do_div'
__base = (base); \
^~~~~~~~~~~~~~~
mm/page_alloc.c:8378:3: note: Left side of '&&' is false
do_div(tmp, lowmem_pages);
^
arch/x86/include/asm/div64.h:26:35: note: expanded from macro 'do_div'
if (__builtin_constant_p(__base) && is_power_of_2(__base)) { \
^
mm/page_alloc.c:8378:3: note: Assuming '__high' is not equal to 0
do_div(tmp, lowmem_pages);
^
arch/x86/include/asm/div64.h:32:7: note: expanded from macro 'do_div'
if (__high) { \
^~~~~~
mm/page_alloc.c:8378:3: note: Taking true branch
do_div(tmp, lowmem_pages);
^
arch/x86/include/asm/div64.h:32:3: note: expanded from macro 'do_div'
if (__high) { \
^
mm/page_alloc.c:8378:3: note: Division by zero
do_div(tmp, lowmem_pages);
^
arch/x86/include/asm/div64.h:33:21: note: expanded from macro 'do_div'
__upper = __high % (__base); \
~~~~~~~^~~~~~~~~~
Suppressed 8 warnings (7 in non-user code, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings generated.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
Suppressed 5 warnings (4 in non-user code, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
4 warnings generated.
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5 warnings generated.
>> fs/erofs/xattr.c:204:10: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs);
^
fs/erofs/xattr.c:628:6: note: Assuming 'rcu' is false
if (rcu)
^~~
fs/erofs/xattr.c:628:2: note: Taking false branch
if (rcu)
^
fs/erofs/xattr.c:631:2: note: Control jumps to 'case 16384:' at line 635
switch (type) {
^
fs/erofs/xattr.c:637:3: note: Execution continues on line 642
break;
^
fs/erofs/xattr.c:642:7: note: Calling 'erofs_getxattr'
rc = erofs_getxattr(inode, prefix, "", NULL, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:399:7: note: 'name' is non-null
if (!name)
^~~~
fs/erofs/xattr.c:399:2: note: Taking false branch
if (!name)
^
fs/erofs/xattr.c:403:6: note: 'ret' is 0
if (ret)
^~~
fs/erofs/xattr.c:403:2: note: Taking false branch
if (ret)
^
fs/erofs/xattr.c:408:14: note: Field 'len' is <= EROFS_NAME_LEN
if (it.name.len > EROFS_NAME_LEN)
^
fs/erofs/xattr.c:408:2: note: Taking false branch
if (it.name.len > EROFS_NAME_LEN)
^
fs/erofs/xattr.c:418:8: note: Calling 'inline_getxattr'
ret = inline_getxattr(inode, &it);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:343:8: note: Calling 'inline_xattr_iter_begin'
ret = inline_xattr_iter_begin(&it->it, inode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:165:6: note: Assuming 'xattr_header_sz' is < field 'xattr_isize'
if (xattr_header_sz >= vi->xattr_isize) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:165:2: note: Taking false branch
if (xattr_header_sz >= vi->xattr_isize) {
^
fs/erofs/xattr.c:177:2: note: Taking false branch
if (IS_ERR(it->kaddr))
^
fs/erofs/xattr.c:343:8: note: Returning from 'inline_xattr_iter_begin'
ret = inline_xattr_iter_begin(&it->it, inode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:344:6: note: 'ret' is >= 0
if (ret < 0)
^~~
fs/erofs/xattr.c:344:2: note: Taking false branch
if (ret < 0)
^
fs/erofs/xattr.c:348:2: note: Loop condition is true. Entering loop body
while (remaining) {
^
fs/erofs/xattr.c:349:9: note: Calling 'xattr_foreach'
ret = xattr_foreach(&it->it, &find_xattr_handlers, &remaining);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:195:8: note: Calling 'xattr_iter_fixup'
err = xattr_iter_fixup(it);
^~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:145:6: note: Assuming the condition is false
if (it->ofs < EROFS_BLKSIZ)
^~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:145:2: note: Taking false branch
if (it->ofs < EROFS_BLKSIZ)
^
fs/erofs/xattr.c:149:2: note: Value assigned to 'it.it.kaddr'
it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:151:6: note: Assuming the condition is true
if (IS_ERR(it->kaddr))
^~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:151:2: note: Taking true branch
if (IS_ERR(it->kaddr))
^
fs/erofs/xattr.c:152:3: note: Returning value, which participates in a condition later
return PTR_ERR(it->kaddr);
^~~~~~~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:195:8: note: Returning from 'xattr_iter_fixup'
err = xattr_iter_fixup(it);
^~~~~~~~~~~~~~~~~~~~
fs/erofs/xattr.c:196:6: note: Assuming 'err' is 0
if (err)
^~~
fs/erofs/xattr.c:196:2: note: Taking false branch
if (err)
^
fs/erofs/xattr.c:204:10: note: Dereference of null pointer
entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 4 warnings (4 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
vim +204 fs/erofs/xattr.c
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 181
bdf30cef10558d drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 182 /*
bdf30cef10558d drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 183 * Regardless of success or failure, `xattr_foreach' will end up with
bdf30cef10558d drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 184 * `ofs' pointing to the next xattr item rather than an arbitrary position.
bdf30cef10558d drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 185 */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 186 static int xattr_foreach(struct xattr_iter *it,
447a3621b3835b drivers/staging/erofs/xattr.c Julian Merida 2019-03-18 187 const struct xattr_iter_handlers *op,
447a3621b3835b drivers/staging/erofs/xattr.c Julian Merida 2019-03-18 188 unsigned int *tlimit)
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 189 {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 190 struct erofs_xattr_entry entry;
7dd68b147d60e5 drivers/staging/erofs/xattr.c Thomas Weißschuh 2018-09-10 191 unsigned int value_sz, processed, slice;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 192 int err;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 193
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 194 /* 0. fixup blkaddr, ofs, ipage */
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 195 err = xattr_iter_fixup(it);
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 196 if (err)
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 197 return err;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 198
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 199 /*
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 200 * 1. read xattr entry to the memory,
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 201 * since we do EROFS_XATTR_ALIGN
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 202 * therefore entry should be in the page
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 203 */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 @204 entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs);
561fb35a9d04ca drivers/staging/erofs/xattr.c Bhanusree Pola 2019-03-22 205 if (tlimit) {
b6796abd3cc155 fs/erofs/xattr.c Gao Xiang 2019-09-04 206 unsigned int entry_sz = erofs_xattr_entry_size(&entry);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 207
9ddc7004f6aae6 drivers/staging/erofs/xattr.c Gao Xiang 2019-08-13 208 /* xattr on-disk corruption: xattr entry beyond xattr_isize */
8d8a09b093d707 fs/erofs/xattr.c Gao Xiang 2019-08-30 209 if (*tlimit < entry_sz) {
9ddc7004f6aae6 drivers/staging/erofs/xattr.c Gao Xiang 2019-08-13 210 DBG_BUGON(1);
a6b9b1d5eae61a drivers/staging/erofs/xattr.c Gao Xiang 2019-08-14 211 return -EFSCORRUPTED;
9ddc7004f6aae6 drivers/staging/erofs/xattr.c Gao Xiang 2019-08-13 212 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 213 *tlimit -= entry_sz;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 214 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 215
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 216 it->ofs += sizeof(struct erofs_xattr_entry);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 217 value_sz = le16_to_cpu(entry.e_value_size);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 218
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 219 /* handle entry */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 220 err = op->entry(it, &entry);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 221 if (err) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 222 it->ofs += entry.e_name_len + value_sz;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 223 goto out;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 224 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 225
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 226 /* 2. handle xattr name (ofs will finally be at the end of name) */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 227 processed = 0;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 228
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 229 while (processed < entry.e_name_len) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 230 if (it->ofs >= EROFS_BLKSIZ) {
9ddc7004f6aae6 drivers/staging/erofs/xattr.c Gao Xiang 2019-08-13 231 DBG_BUGON(it->ofs > EROFS_BLKSIZ);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 232
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 233 err = xattr_iter_fixup(it);
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 234 if (err)
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 235 goto out;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 236 it->ofs = 0;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 237 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 238
d7c5cceeea80de fs/erofs/xattr.c Gao Xiang 2022-01-02 239 slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 240 entry.e_name_len - processed);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 241
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 242 /* handle name */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 243 err = op->name(it, processed, it->kaddr + it->ofs, slice);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 244 if (err) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 245 it->ofs += entry.e_name_len - processed + value_sz;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 246 goto out;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 247 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 248
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 249 it->ofs += slice;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 250 processed += slice;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 251 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 252
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 253 /* 3. handle xattr value */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 254 processed = 0;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 255
561fb35a9d04ca drivers/staging/erofs/xattr.c Bhanusree Pola 2019-03-22 256 if (op->alloc_buffer) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 257 err = op->alloc_buffer(it, value_sz);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 258 if (err) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 259 it->ofs += value_sz;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 260 goto out;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 261 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 262 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 263
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 264 while (processed < value_sz) {
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 265 if (it->ofs >= EROFS_BLKSIZ) {
9ddc7004f6aae6 drivers/staging/erofs/xattr.c Gao Xiang 2019-08-13 266 DBG_BUGON(it->ofs > EROFS_BLKSIZ);
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 267
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 268 err = xattr_iter_fixup(it);
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 269 if (err)
cadf1ccf1b0021 drivers/staging/erofs/xattr.c Gao Xiang 2018-08-21 270 goto out;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 271 it->ofs = 0;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 272 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 273
d7c5cceeea80de fs/erofs/xattr.c Gao Xiang 2022-01-02 274 slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 275 value_sz - processed);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 276 op->value(it, processed, it->kaddr + it->ofs, slice);
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 277 it->ofs += slice;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 278 processed += slice;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 279 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 280
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 281 out:
bdf30cef10558d drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 282 /* xattrs should be 4-byte aligned (on-disk constraint) */
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 283 it->ofs = EROFS_XATTR_ALIGN(it->ofs);
6614f76530c102 drivers/staging/erofs/xattr.c Gao Xiang 2018-09-19 284 return err < 0 ? err : 0;
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 285 }
b17500a0fdbae1 drivers/staging/erofs/xattr.c Gao Xiang 2018-07-26 286
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/5] erofs: use meta buffers for xattr operations
2022-01-02 4:00 ` Gao Xiang
@ 2022-01-04 8:07 ` Chao Yu
-1 siblings, 0 replies; 7+ messages in thread
From: Chao Yu @ 2022-01-04 8:07 UTC (permalink / raw)
To: Gao Xiang, linux-erofs, Liu Bo; +Cc: LKML, Yue Hu
On 2022/1/2 12:00, Gao Xiang wrote:
> Get rid of old erofs_get_meta_page() within xattr operations by
> using on-stack meta buffers in order to prepare subpage and folio
> features.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/5] erofs: use meta buffers for xattr operations
@ 2022-01-04 8:07 ` Chao Yu
0 siblings, 0 replies; 7+ messages in thread
From: Chao Yu @ 2022-01-04 8:07 UTC (permalink / raw)
To: Gao Xiang, linux-erofs, Liu Bo; +Cc: Yue Hu, LKML
On 2022/1/2 12:00, Gao Xiang wrote:
> Get rid of old erofs_get_meta_page() within xattr operations by
> using on-stack meta buffers in order to prepare subpage and folio
> features.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/5] erofs: use meta buffers for xattr operations
2022-01-02 4:00 ` Gao Xiang
@ 2022-01-02 7:48 ` Liu Bo
-1 siblings, 0 replies; 7+ messages in thread
From: Liu Bo @ 2022-01-02 7:48 UTC (permalink / raw)
To: Gao Xiang; +Cc: linux-erofs, Chao Yu, LKML, Yue Hu
On Sun, Jan 02, 2022 at 12:00:16PM +0800, Gao Xiang wrote:
> Get rid of old erofs_get_meta_page() within xattr operations by
> using on-stack meta buffers in order to prepare subpage and folio
> features.
>
Reviewed-by: Liu Bo <bo.liu@linux.alibaba.com>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/xattr.c | 134 ++++++++++++++---------------------------------
> 1 file changed, 40 insertions(+), 94 deletions(-)
>
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 01c581e93c5f..437ff6e7293d 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -8,33 +8,13 @@
>
> struct xattr_iter {
> struct super_block *sb;
> - struct page *page;
> + struct erofs_buf buf;
> void *kaddr;
>
> erofs_blk_t blkaddr;
> unsigned int ofs;
> };
>
> -static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
> -{
> - /* the only user of kunmap() is 'init_inode_xattrs' */
> - if (!atomic)
> - kunmap(it->page);
> - else
> - kunmap_atomic(it->kaddr);
> -
> - unlock_page(it->page);
> - put_page(it->page);
> -}
> -
> -static inline void xattr_iter_end_final(struct xattr_iter *it)
> -{
> - if (!it->page)
> - return;
> -
> - xattr_iter_end(it, true);
> -}
> -
> static int init_inode_xattrs(struct inode *inode)
> {
> struct erofs_inode *const vi = EROFS_I(inode);
> @@ -43,7 +23,6 @@ static int init_inode_xattrs(struct inode *inode)
> struct erofs_xattr_ibody_header *ih;
> struct super_block *sb;
> struct erofs_sb_info *sbi;
> - bool atomic_map;
> int ret = 0;
>
> /* the most case is that xattrs of this inode are initialized. */
> @@ -91,26 +70,23 @@ static int init_inode_xattrs(struct inode *inode)
>
> sb = inode->i_sb;
> sbi = EROFS_SB(sb);
> + it.buf = __EROFS_BUF_INITIALIZER;
> it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize);
> it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
>
> - it.page = erofs_get_meta_page(sb, it.blkaddr);
> - if (IS_ERR(it.page)) {
> - ret = PTR_ERR(it.page);
> + /* read in shared xattr array (non-atomic, see kmalloc below) */
> + it.kaddr = erofs_read_metabuf(&it.buf, sb, it.blkaddr, EROFS_KMAP);
> + if (IS_ERR(it.kaddr)) {
> + ret = PTR_ERR(it.kaddr);
> goto out_unlock;
> }
>
> - /* read in shared xattr array (non-atomic, see kmalloc below) */
> - it.kaddr = kmap(it.page);
> - atomic_map = false;
> -
> ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
> -
> vi->xattr_shared_count = ih->h_shared_count;
> vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
> sizeof(uint), GFP_KERNEL);
> if (!vi->xattr_shared_xattrs) {
> - xattr_iter_end(&it, atomic_map);
> + erofs_put_metabuf(&it.buf);
> ret = -ENOMEM;
> goto out_unlock;
> }
> @@ -122,25 +98,22 @@ static int init_inode_xattrs(struct inode *inode)
> if (it.ofs >= EROFS_BLKSIZ) {
> /* cannot be unaligned */
> DBG_BUGON(it.ofs != EROFS_BLKSIZ);
> - xattr_iter_end(&it, atomic_map);
>
> - it.page = erofs_get_meta_page(sb, ++it.blkaddr);
> - if (IS_ERR(it.page)) {
> + it.kaddr = erofs_read_metabuf(&it.buf, sb, ++it.blkaddr,
> + EROFS_KMAP);
> + if (IS_ERR(it.kaddr)) {
> kfree(vi->xattr_shared_xattrs);
> vi->xattr_shared_xattrs = NULL;
> - ret = PTR_ERR(it.page);
> + ret = PTR_ERR(it.kaddr);
> goto out_unlock;
> }
> -
> - it.kaddr = kmap_atomic(it.page);
> - atomic_map = true;
> it.ofs = 0;
> }
> vi->xattr_shared_xattrs[i] =
> le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs));
> it.ofs += sizeof(__le32);
> }
> - xattr_iter_end(&it, atomic_map);
> + erofs_put_metabuf(&it.buf);
>
> /* paired with smp_mb() at the beginning of the function. */
> smp_mb();
> @@ -172,19 +145,11 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
> if (it->ofs < EROFS_BLKSIZ)
> return 0;
>
> - xattr_iter_end(it, true);
> -
> it->blkaddr += erofs_blknr(it->ofs);
> -
> - it->page = erofs_get_meta_page(it->sb, it->blkaddr);
> - if (IS_ERR(it->page)) {
> - int err = PTR_ERR(it->page);
> -
> - it->page = NULL;
> - return err;
> - }
> -
> - it->kaddr = kmap_atomic(it->page);
> + it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->kaddr))
> + return PTR_ERR(it->kaddr);
> it->ofs = erofs_blkoff(it->ofs);
> return 0;
> }
> @@ -207,11 +172,10 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
> it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs);
> it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
>
> - it->page = erofs_get_meta_page(inode->i_sb, it->blkaddr);
> - if (IS_ERR(it->page))
> - return PTR_ERR(it->page);
> -
> - it->kaddr = kmap_atomic(it->page);
> + it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->kaddr))
> + return PTR_ERR(it->kaddr);
> return vi->xattr_isize - xattr_header_sz;
> }
>
> @@ -272,7 +236,7 @@ static int xattr_foreach(struct xattr_iter *it,
> it->ofs = 0;
> }
>
> - slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
> + slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
> entry.e_name_len - processed);
>
> /* handle name */
> @@ -307,7 +271,7 @@ static int xattr_foreach(struct xattr_iter *it,
> it->ofs = 0;
> }
>
> - slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
> + slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
> value_sz - processed);
> op->value(it, processed, it->kaddr + it->ofs, slice);
> it->ofs += slice;
> @@ -386,8 +350,6 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
> if (ret != -ENOATTR)
> break;
> }
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_size;
> }
>
> @@ -404,26 +366,16 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
> xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> -
> - if (!i || blkaddr != it->it.blkaddr) {
> - if (i)
> - xattr_iter_end(&it->it, true);
> -
> - it->it.page = erofs_get_meta_page(sb, blkaddr);
> - if (IS_ERR(it->it.page))
> - return PTR_ERR(it->it.page);
> -
> - it->it.kaddr = kmap_atomic(it->it.page);
> - it->it.blkaddr = blkaddr;
> - }
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->it.kaddr))
> + return PTR_ERR(it->it.kaddr);
> + it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
> if (ret != -ENOATTR)
> break;
> }
> - if (vi->xattr_shared_count)
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_size;
> }
>
> @@ -452,10 +404,11 @@ int erofs_getxattr(struct inode *inode, int index,
> return ret;
>
> it.index = index;
> -
> it.name.len = strlen(name);
> if (it.name.len > EROFS_NAME_LEN)
> return -ERANGE;
> +
> + it.it.buf = __EROFS_BUF_INITIALIZER;
> it.name.name = name;
>
> it.buffer = buffer;
> @@ -465,6 +418,7 @@ int erofs_getxattr(struct inode *inode, int index,
> ret = inline_getxattr(inode, &it);
> if (ret == -ENOATTR)
> ret = shared_getxattr(inode, &it);
> + erofs_put_metabuf(&it.it.buf);
> return ret;
> }
>
> @@ -607,7 +561,6 @@ static int inline_listxattr(struct listxattr_iter *it)
> if (ret)
> break;
> }
> - xattr_iter_end_final(&it->it);
> return ret ? ret : it->buffer_ofs;
> }
>
> @@ -625,25 +578,16 @@ static int shared_listxattr(struct listxattr_iter *it)
> xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> - if (!i || blkaddr != it->it.blkaddr) {
> - if (i)
> - xattr_iter_end(&it->it, true);
> -
> - it->it.page = erofs_get_meta_page(sb, blkaddr);
> - if (IS_ERR(it->it.page))
> - return PTR_ERR(it->it.page);
> -
> - it->it.kaddr = kmap_atomic(it->it.page);
> - it->it.blkaddr = blkaddr;
> - }
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->it.kaddr))
> + return PTR_ERR(it->it.kaddr);
> + it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
> if (ret)
> break;
> }
> - if (vi->xattr_shared_count)
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_ofs;
> }
>
> @@ -659,6 +603,7 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> if (ret)
> return ret;
>
> + it.it.buf = __EROFS_BUF_INITIALIZER;
> it.dentry = dentry;
> it.buffer = buffer;
> it.buffer_size = buffer_size;
> @@ -667,9 +612,10 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> it.it.sb = dentry->d_sb;
>
> ret = inline_listxattr(&it);
> - if (ret < 0 && ret != -ENOATTR)
> - return ret;
> - return shared_listxattr(&it);
> + if (ret >= 0 || ret == -ENOATTR)
> + ret = shared_listxattr(&it);
> + erofs_put_metabuf(&it.it.buf);
> + return ret;
> }
>
> #ifdef CONFIG_EROFS_FS_POSIX_ACL
> --
> 2.24.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/5] erofs: use meta buffers for xattr operations
@ 2022-01-02 7:48 ` Liu Bo
0 siblings, 0 replies; 7+ messages in thread
From: Liu Bo @ 2022-01-02 7:48 UTC (permalink / raw)
To: Gao Xiang; +Cc: Yue Hu, linux-erofs, LKML
On Sun, Jan 02, 2022 at 12:00:16PM +0800, Gao Xiang wrote:
> Get rid of old erofs_get_meta_page() within xattr operations by
> using on-stack meta buffers in order to prepare subpage and folio
> features.
>
Reviewed-by: Liu Bo <bo.liu@linux.alibaba.com>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/xattr.c | 134 ++++++++++++++---------------------------------
> 1 file changed, 40 insertions(+), 94 deletions(-)
>
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 01c581e93c5f..437ff6e7293d 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -8,33 +8,13 @@
>
> struct xattr_iter {
> struct super_block *sb;
> - struct page *page;
> + struct erofs_buf buf;
> void *kaddr;
>
> erofs_blk_t blkaddr;
> unsigned int ofs;
> };
>
> -static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
> -{
> - /* the only user of kunmap() is 'init_inode_xattrs' */
> - if (!atomic)
> - kunmap(it->page);
> - else
> - kunmap_atomic(it->kaddr);
> -
> - unlock_page(it->page);
> - put_page(it->page);
> -}
> -
> -static inline void xattr_iter_end_final(struct xattr_iter *it)
> -{
> - if (!it->page)
> - return;
> -
> - xattr_iter_end(it, true);
> -}
> -
> static int init_inode_xattrs(struct inode *inode)
> {
> struct erofs_inode *const vi = EROFS_I(inode);
> @@ -43,7 +23,6 @@ static int init_inode_xattrs(struct inode *inode)
> struct erofs_xattr_ibody_header *ih;
> struct super_block *sb;
> struct erofs_sb_info *sbi;
> - bool atomic_map;
> int ret = 0;
>
> /* the most case is that xattrs of this inode are initialized. */
> @@ -91,26 +70,23 @@ static int init_inode_xattrs(struct inode *inode)
>
> sb = inode->i_sb;
> sbi = EROFS_SB(sb);
> + it.buf = __EROFS_BUF_INITIALIZER;
> it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize);
> it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
>
> - it.page = erofs_get_meta_page(sb, it.blkaddr);
> - if (IS_ERR(it.page)) {
> - ret = PTR_ERR(it.page);
> + /* read in shared xattr array (non-atomic, see kmalloc below) */
> + it.kaddr = erofs_read_metabuf(&it.buf, sb, it.blkaddr, EROFS_KMAP);
> + if (IS_ERR(it.kaddr)) {
> + ret = PTR_ERR(it.kaddr);
> goto out_unlock;
> }
>
> - /* read in shared xattr array (non-atomic, see kmalloc below) */
> - it.kaddr = kmap(it.page);
> - atomic_map = false;
> -
> ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
> -
> vi->xattr_shared_count = ih->h_shared_count;
> vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
> sizeof(uint), GFP_KERNEL);
> if (!vi->xattr_shared_xattrs) {
> - xattr_iter_end(&it, atomic_map);
> + erofs_put_metabuf(&it.buf);
> ret = -ENOMEM;
> goto out_unlock;
> }
> @@ -122,25 +98,22 @@ static int init_inode_xattrs(struct inode *inode)
> if (it.ofs >= EROFS_BLKSIZ) {
> /* cannot be unaligned */
> DBG_BUGON(it.ofs != EROFS_BLKSIZ);
> - xattr_iter_end(&it, atomic_map);
>
> - it.page = erofs_get_meta_page(sb, ++it.blkaddr);
> - if (IS_ERR(it.page)) {
> + it.kaddr = erofs_read_metabuf(&it.buf, sb, ++it.blkaddr,
> + EROFS_KMAP);
> + if (IS_ERR(it.kaddr)) {
> kfree(vi->xattr_shared_xattrs);
> vi->xattr_shared_xattrs = NULL;
> - ret = PTR_ERR(it.page);
> + ret = PTR_ERR(it.kaddr);
> goto out_unlock;
> }
> -
> - it.kaddr = kmap_atomic(it.page);
> - atomic_map = true;
> it.ofs = 0;
> }
> vi->xattr_shared_xattrs[i] =
> le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs));
> it.ofs += sizeof(__le32);
> }
> - xattr_iter_end(&it, atomic_map);
> + erofs_put_metabuf(&it.buf);
>
> /* paired with smp_mb() at the beginning of the function. */
> smp_mb();
> @@ -172,19 +145,11 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
> if (it->ofs < EROFS_BLKSIZ)
> return 0;
>
> - xattr_iter_end(it, true);
> -
> it->blkaddr += erofs_blknr(it->ofs);
> -
> - it->page = erofs_get_meta_page(it->sb, it->blkaddr);
> - if (IS_ERR(it->page)) {
> - int err = PTR_ERR(it->page);
> -
> - it->page = NULL;
> - return err;
> - }
> -
> - it->kaddr = kmap_atomic(it->page);
> + it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->kaddr))
> + return PTR_ERR(it->kaddr);
> it->ofs = erofs_blkoff(it->ofs);
> return 0;
> }
> @@ -207,11 +172,10 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
> it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs);
> it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
>
> - it->page = erofs_get_meta_page(inode->i_sb, it->blkaddr);
> - if (IS_ERR(it->page))
> - return PTR_ERR(it->page);
> -
> - it->kaddr = kmap_atomic(it->page);
> + it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->kaddr))
> + return PTR_ERR(it->kaddr);
> return vi->xattr_isize - xattr_header_sz;
> }
>
> @@ -272,7 +236,7 @@ static int xattr_foreach(struct xattr_iter *it,
> it->ofs = 0;
> }
>
> - slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
> + slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
> entry.e_name_len - processed);
>
> /* handle name */
> @@ -307,7 +271,7 @@ static int xattr_foreach(struct xattr_iter *it,
> it->ofs = 0;
> }
>
> - slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
> + slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
> value_sz - processed);
> op->value(it, processed, it->kaddr + it->ofs, slice);
> it->ofs += slice;
> @@ -386,8 +350,6 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
> if (ret != -ENOATTR)
> break;
> }
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_size;
> }
>
> @@ -404,26 +366,16 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
> xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> -
> - if (!i || blkaddr != it->it.blkaddr) {
> - if (i)
> - xattr_iter_end(&it->it, true);
> -
> - it->it.page = erofs_get_meta_page(sb, blkaddr);
> - if (IS_ERR(it->it.page))
> - return PTR_ERR(it->it.page);
> -
> - it->it.kaddr = kmap_atomic(it->it.page);
> - it->it.blkaddr = blkaddr;
> - }
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->it.kaddr))
> + return PTR_ERR(it->it.kaddr);
> + it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
> if (ret != -ENOATTR)
> break;
> }
> - if (vi->xattr_shared_count)
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_size;
> }
>
> @@ -452,10 +404,11 @@ int erofs_getxattr(struct inode *inode, int index,
> return ret;
>
> it.index = index;
> -
> it.name.len = strlen(name);
> if (it.name.len > EROFS_NAME_LEN)
> return -ERANGE;
> +
> + it.it.buf = __EROFS_BUF_INITIALIZER;
> it.name.name = name;
>
> it.buffer = buffer;
> @@ -465,6 +418,7 @@ int erofs_getxattr(struct inode *inode, int index,
> ret = inline_getxattr(inode, &it);
> if (ret == -ENOATTR)
> ret = shared_getxattr(inode, &it);
> + erofs_put_metabuf(&it.it.buf);
> return ret;
> }
>
> @@ -607,7 +561,6 @@ static int inline_listxattr(struct listxattr_iter *it)
> if (ret)
> break;
> }
> - xattr_iter_end_final(&it->it);
> return ret ? ret : it->buffer_ofs;
> }
>
> @@ -625,25 +578,16 @@ static int shared_listxattr(struct listxattr_iter *it)
> xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
>
> it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
> - if (!i || blkaddr != it->it.blkaddr) {
> - if (i)
> - xattr_iter_end(&it->it, true);
> -
> - it->it.page = erofs_get_meta_page(sb, blkaddr);
> - if (IS_ERR(it->it.page))
> - return PTR_ERR(it->it.page);
> -
> - it->it.kaddr = kmap_atomic(it->it.page);
> - it->it.blkaddr = blkaddr;
> - }
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> + EROFS_KMAP_ATOMIC);
> + if (IS_ERR(it->it.kaddr))
> + return PTR_ERR(it->it.kaddr);
> + it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
> if (ret)
> break;
> }
> - if (vi->xattr_shared_count)
> - xattr_iter_end_final(&it->it);
> -
> return ret ? ret : it->buffer_ofs;
> }
>
> @@ -659,6 +603,7 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> if (ret)
> return ret;
>
> + it.it.buf = __EROFS_BUF_INITIALIZER;
> it.dentry = dentry;
> it.buffer = buffer;
> it.buffer_size = buffer_size;
> @@ -667,9 +612,10 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> it.it.sb = dentry->d_sb;
>
> ret = inline_listxattr(&it);
> - if (ret < 0 && ret != -ENOATTR)
> - return ret;
> - return shared_listxattr(&it);
> + if (ret >= 0 || ret == -ENOATTR)
> + ret = shared_listxattr(&it);
> + erofs_put_metabuf(&it.it.buf);
> + return ret;
> }
>
> #ifdef CONFIG_EROFS_FS_POSIX_ACL
> --
> 2.24.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 4/5] erofs: use meta buffers for xattr operations
2022-01-02 4:00 [PATCH v2 0/5] erofs: get rid of erofs_get_meta_page() Gao Xiang
@ 2022-01-02 4:00 ` Gao Xiang
0 siblings, 0 replies; 7+ messages in thread
From: Gao Xiang @ 2022-01-02 4:00 UTC (permalink / raw)
To: linux-erofs, Chao Yu, Liu Bo; +Cc: LKML, Yue Hu, Gao Xiang
Get rid of old erofs_get_meta_page() within xattr operations by
using on-stack meta buffers in order to prepare subpage and folio
features.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/xattr.c | 134 ++++++++++++++---------------------------------
1 file changed, 40 insertions(+), 94 deletions(-)
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index 01c581e93c5f..437ff6e7293d 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -8,33 +8,13 @@
struct xattr_iter {
struct super_block *sb;
- struct page *page;
+ struct erofs_buf buf;
void *kaddr;
erofs_blk_t blkaddr;
unsigned int ofs;
};
-static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
-{
- /* the only user of kunmap() is 'init_inode_xattrs' */
- if (!atomic)
- kunmap(it->page);
- else
- kunmap_atomic(it->kaddr);
-
- unlock_page(it->page);
- put_page(it->page);
-}
-
-static inline void xattr_iter_end_final(struct xattr_iter *it)
-{
- if (!it->page)
- return;
-
- xattr_iter_end(it, true);
-}
-
static int init_inode_xattrs(struct inode *inode)
{
struct erofs_inode *const vi = EROFS_I(inode);
@@ -43,7 +23,6 @@ static int init_inode_xattrs(struct inode *inode)
struct erofs_xattr_ibody_header *ih;
struct super_block *sb;
struct erofs_sb_info *sbi;
- bool atomic_map;
int ret = 0;
/* the most case is that xattrs of this inode are initialized. */
@@ -91,26 +70,23 @@ static int init_inode_xattrs(struct inode *inode)
sb = inode->i_sb;
sbi = EROFS_SB(sb);
+ it.buf = __EROFS_BUF_INITIALIZER;
it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize);
it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
- it.page = erofs_get_meta_page(sb, it.blkaddr);
- if (IS_ERR(it.page)) {
- ret = PTR_ERR(it.page);
+ /* read in shared xattr array (non-atomic, see kmalloc below) */
+ it.kaddr = erofs_read_metabuf(&it.buf, sb, it.blkaddr, EROFS_KMAP);
+ if (IS_ERR(it.kaddr)) {
+ ret = PTR_ERR(it.kaddr);
goto out_unlock;
}
- /* read in shared xattr array (non-atomic, see kmalloc below) */
- it.kaddr = kmap(it.page);
- atomic_map = false;
-
ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
-
vi->xattr_shared_count = ih->h_shared_count;
vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
sizeof(uint), GFP_KERNEL);
if (!vi->xattr_shared_xattrs) {
- xattr_iter_end(&it, atomic_map);
+ erofs_put_metabuf(&it.buf);
ret = -ENOMEM;
goto out_unlock;
}
@@ -122,25 +98,22 @@ static int init_inode_xattrs(struct inode *inode)
if (it.ofs >= EROFS_BLKSIZ) {
/* cannot be unaligned */
DBG_BUGON(it.ofs != EROFS_BLKSIZ);
- xattr_iter_end(&it, atomic_map);
- it.page = erofs_get_meta_page(sb, ++it.blkaddr);
- if (IS_ERR(it.page)) {
+ it.kaddr = erofs_read_metabuf(&it.buf, sb, ++it.blkaddr,
+ EROFS_KMAP);
+ if (IS_ERR(it.kaddr)) {
kfree(vi->xattr_shared_xattrs);
vi->xattr_shared_xattrs = NULL;
- ret = PTR_ERR(it.page);
+ ret = PTR_ERR(it.kaddr);
goto out_unlock;
}
-
- it.kaddr = kmap_atomic(it.page);
- atomic_map = true;
it.ofs = 0;
}
vi->xattr_shared_xattrs[i] =
le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs));
it.ofs += sizeof(__le32);
}
- xattr_iter_end(&it, atomic_map);
+ erofs_put_metabuf(&it.buf);
/* paired with smp_mb() at the beginning of the function. */
smp_mb();
@@ -172,19 +145,11 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
if (it->ofs < EROFS_BLKSIZ)
return 0;
- xattr_iter_end(it, true);
-
it->blkaddr += erofs_blknr(it->ofs);
-
- it->page = erofs_get_meta_page(it->sb, it->blkaddr);
- if (IS_ERR(it->page)) {
- int err = PTR_ERR(it->page);
-
- it->page = NULL;
- return err;
- }
-
- it->kaddr = kmap_atomic(it->page);
+ it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->kaddr))
+ return PTR_ERR(it->kaddr);
it->ofs = erofs_blkoff(it->ofs);
return 0;
}
@@ -207,11 +172,10 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs);
it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
- it->page = erofs_get_meta_page(inode->i_sb, it->blkaddr);
- if (IS_ERR(it->page))
- return PTR_ERR(it->page);
-
- it->kaddr = kmap_atomic(it->page);
+ it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->kaddr))
+ return PTR_ERR(it->kaddr);
return vi->xattr_isize - xattr_header_sz;
}
@@ -272,7 +236,7 @@ static int xattr_foreach(struct xattr_iter *it,
it->ofs = 0;
}
- slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
+ slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
entry.e_name_len - processed);
/* handle name */
@@ -307,7 +271,7 @@ static int xattr_foreach(struct xattr_iter *it,
it->ofs = 0;
}
- slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
+ slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
value_sz - processed);
op->value(it, processed, it->kaddr + it->ofs, slice);
it->ofs += slice;
@@ -386,8 +350,6 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
if (ret != -ENOATTR)
break;
}
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_size;
}
@@ -404,26 +366,16 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
-
- if (!i || blkaddr != it->it.blkaddr) {
- if (i)
- xattr_iter_end(&it->it, true);
-
- it->it.page = erofs_get_meta_page(sb, blkaddr);
- if (IS_ERR(it->it.page))
- return PTR_ERR(it->it.page);
-
- it->it.kaddr = kmap_atomic(it->it.page);
- it->it.blkaddr = blkaddr;
- }
+ it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->it.kaddr))
+ return PTR_ERR(it->it.kaddr);
+ it->it.blkaddr = blkaddr;
ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
if (ret != -ENOATTR)
break;
}
- if (vi->xattr_shared_count)
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_size;
}
@@ -452,10 +404,11 @@ int erofs_getxattr(struct inode *inode, int index,
return ret;
it.index = index;
-
it.name.len = strlen(name);
if (it.name.len > EROFS_NAME_LEN)
return -ERANGE;
+
+ it.it.buf = __EROFS_BUF_INITIALIZER;
it.name.name = name;
it.buffer = buffer;
@@ -465,6 +418,7 @@ int erofs_getxattr(struct inode *inode, int index,
ret = inline_getxattr(inode, &it);
if (ret == -ENOATTR)
ret = shared_getxattr(inode, &it);
+ erofs_put_metabuf(&it.it.buf);
return ret;
}
@@ -607,7 +561,6 @@ static int inline_listxattr(struct listxattr_iter *it)
if (ret)
break;
}
- xattr_iter_end_final(&it->it);
return ret ? ret : it->buffer_ofs;
}
@@ -625,25 +578,16 @@ static int shared_listxattr(struct listxattr_iter *it)
xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
- if (!i || blkaddr != it->it.blkaddr) {
- if (i)
- xattr_iter_end(&it->it, true);
-
- it->it.page = erofs_get_meta_page(sb, blkaddr);
- if (IS_ERR(it->it.page))
- return PTR_ERR(it->it.page);
-
- it->it.kaddr = kmap_atomic(it->it.page);
- it->it.blkaddr = blkaddr;
- }
+ it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->it.kaddr))
+ return PTR_ERR(it->it.kaddr);
+ it->it.blkaddr = blkaddr;
ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
if (ret)
break;
}
- if (vi->xattr_shared_count)
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_ofs;
}
@@ -659,6 +603,7 @@ ssize_t erofs_listxattr(struct dentry *dentry,
if (ret)
return ret;
+ it.it.buf = __EROFS_BUF_INITIALIZER;
it.dentry = dentry;
it.buffer = buffer;
it.buffer_size = buffer_size;
@@ -667,9 +612,10 @@ ssize_t erofs_listxattr(struct dentry *dentry,
it.it.sb = dentry->d_sb;
ret = inline_listxattr(&it);
- if (ret < 0 && ret != -ENOATTR)
- return ret;
- return shared_listxattr(&it);
+ if (ret >= 0 || ret == -ENOATTR)
+ ret = shared_listxattr(&it);
+ erofs_put_metabuf(&it.it.buf);
+ return ret;
}
#ifdef CONFIG_EROFS_FS_POSIX_ACL
--
2.24.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/5] erofs: use meta buffers for xattr operations
@ 2022-01-02 4:00 ` Gao Xiang
0 siblings, 0 replies; 7+ messages in thread
From: Gao Xiang @ 2022-01-02 4:00 UTC (permalink / raw)
To: linux-erofs, Chao Yu, Liu Bo; +Cc: Gao Xiang, Yue Hu, LKML
Get rid of old erofs_get_meta_page() within xattr operations by
using on-stack meta buffers in order to prepare subpage and folio
features.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/xattr.c | 134 ++++++++++++++---------------------------------
1 file changed, 40 insertions(+), 94 deletions(-)
diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index 01c581e93c5f..437ff6e7293d 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -8,33 +8,13 @@
struct xattr_iter {
struct super_block *sb;
- struct page *page;
+ struct erofs_buf buf;
void *kaddr;
erofs_blk_t blkaddr;
unsigned int ofs;
};
-static inline void xattr_iter_end(struct xattr_iter *it, bool atomic)
-{
- /* the only user of kunmap() is 'init_inode_xattrs' */
- if (!atomic)
- kunmap(it->page);
- else
- kunmap_atomic(it->kaddr);
-
- unlock_page(it->page);
- put_page(it->page);
-}
-
-static inline void xattr_iter_end_final(struct xattr_iter *it)
-{
- if (!it->page)
- return;
-
- xattr_iter_end(it, true);
-}
-
static int init_inode_xattrs(struct inode *inode)
{
struct erofs_inode *const vi = EROFS_I(inode);
@@ -43,7 +23,6 @@ static int init_inode_xattrs(struct inode *inode)
struct erofs_xattr_ibody_header *ih;
struct super_block *sb;
struct erofs_sb_info *sbi;
- bool atomic_map;
int ret = 0;
/* the most case is that xattrs of this inode are initialized. */
@@ -91,26 +70,23 @@ static int init_inode_xattrs(struct inode *inode)
sb = inode->i_sb;
sbi = EROFS_SB(sb);
+ it.buf = __EROFS_BUF_INITIALIZER;
it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize);
it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize);
- it.page = erofs_get_meta_page(sb, it.blkaddr);
- if (IS_ERR(it.page)) {
- ret = PTR_ERR(it.page);
+ /* read in shared xattr array (non-atomic, see kmalloc below) */
+ it.kaddr = erofs_read_metabuf(&it.buf, sb, it.blkaddr, EROFS_KMAP);
+ if (IS_ERR(it.kaddr)) {
+ ret = PTR_ERR(it.kaddr);
goto out_unlock;
}
- /* read in shared xattr array (non-atomic, see kmalloc below) */
- it.kaddr = kmap(it.page);
- atomic_map = false;
-
ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs);
-
vi->xattr_shared_count = ih->h_shared_count;
vi->xattr_shared_xattrs = kmalloc_array(vi->xattr_shared_count,
sizeof(uint), GFP_KERNEL);
if (!vi->xattr_shared_xattrs) {
- xattr_iter_end(&it, atomic_map);
+ erofs_put_metabuf(&it.buf);
ret = -ENOMEM;
goto out_unlock;
}
@@ -122,25 +98,22 @@ static int init_inode_xattrs(struct inode *inode)
if (it.ofs >= EROFS_BLKSIZ) {
/* cannot be unaligned */
DBG_BUGON(it.ofs != EROFS_BLKSIZ);
- xattr_iter_end(&it, atomic_map);
- it.page = erofs_get_meta_page(sb, ++it.blkaddr);
- if (IS_ERR(it.page)) {
+ it.kaddr = erofs_read_metabuf(&it.buf, sb, ++it.blkaddr,
+ EROFS_KMAP);
+ if (IS_ERR(it.kaddr)) {
kfree(vi->xattr_shared_xattrs);
vi->xattr_shared_xattrs = NULL;
- ret = PTR_ERR(it.page);
+ ret = PTR_ERR(it.kaddr);
goto out_unlock;
}
-
- it.kaddr = kmap_atomic(it.page);
- atomic_map = true;
it.ofs = 0;
}
vi->xattr_shared_xattrs[i] =
le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs));
it.ofs += sizeof(__le32);
}
- xattr_iter_end(&it, atomic_map);
+ erofs_put_metabuf(&it.buf);
/* paired with smp_mb() at the beginning of the function. */
smp_mb();
@@ -172,19 +145,11 @@ static inline int xattr_iter_fixup(struct xattr_iter *it)
if (it->ofs < EROFS_BLKSIZ)
return 0;
- xattr_iter_end(it, true);
-
it->blkaddr += erofs_blknr(it->ofs);
-
- it->page = erofs_get_meta_page(it->sb, it->blkaddr);
- if (IS_ERR(it->page)) {
- int err = PTR_ERR(it->page);
-
- it->page = NULL;
- return err;
- }
-
- it->kaddr = kmap_atomic(it->page);
+ it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->kaddr))
+ return PTR_ERR(it->kaddr);
it->ofs = erofs_blkoff(it->ofs);
return 0;
}
@@ -207,11 +172,10 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs);
it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs);
- it->page = erofs_get_meta_page(inode->i_sb, it->blkaddr);
- if (IS_ERR(it->page))
- return PTR_ERR(it->page);
-
- it->kaddr = kmap_atomic(it->page);
+ it->kaddr = erofs_read_metabuf(&it->buf, inode->i_sb, it->blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->kaddr))
+ return PTR_ERR(it->kaddr);
return vi->xattr_isize - xattr_header_sz;
}
@@ -272,7 +236,7 @@ static int xattr_foreach(struct xattr_iter *it,
it->ofs = 0;
}
- slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
+ slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
entry.e_name_len - processed);
/* handle name */
@@ -307,7 +271,7 @@ static int xattr_foreach(struct xattr_iter *it,
it->ofs = 0;
}
- slice = min_t(unsigned int, PAGE_SIZE - it->ofs,
+ slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs,
value_sz - processed);
op->value(it, processed, it->kaddr + it->ofs, slice);
it->ofs += slice;
@@ -386,8 +350,6 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
if (ret != -ENOATTR)
break;
}
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_size;
}
@@ -404,26 +366,16 @@ static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
-
- if (!i || blkaddr != it->it.blkaddr) {
- if (i)
- xattr_iter_end(&it->it, true);
-
- it->it.page = erofs_get_meta_page(sb, blkaddr);
- if (IS_ERR(it->it.page))
- return PTR_ERR(it->it.page);
-
- it->it.kaddr = kmap_atomic(it->it.page);
- it->it.blkaddr = blkaddr;
- }
+ it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->it.kaddr))
+ return PTR_ERR(it->it.kaddr);
+ it->it.blkaddr = blkaddr;
ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
if (ret != -ENOATTR)
break;
}
- if (vi->xattr_shared_count)
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_size;
}
@@ -452,10 +404,11 @@ int erofs_getxattr(struct inode *inode, int index,
return ret;
it.index = index;
-
it.name.len = strlen(name);
if (it.name.len > EROFS_NAME_LEN)
return -ERANGE;
+
+ it.it.buf = __EROFS_BUF_INITIALIZER;
it.name.name = name;
it.buffer = buffer;
@@ -465,6 +418,7 @@ int erofs_getxattr(struct inode *inode, int index,
ret = inline_getxattr(inode, &it);
if (ret == -ENOATTR)
ret = shared_getxattr(inode, &it);
+ erofs_put_metabuf(&it.it.buf);
return ret;
}
@@ -607,7 +561,6 @@ static int inline_listxattr(struct listxattr_iter *it)
if (ret)
break;
}
- xattr_iter_end_final(&it->it);
return ret ? ret : it->buffer_ofs;
}
@@ -625,25 +578,16 @@ static int shared_listxattr(struct listxattr_iter *it)
xattrblock_addr(sbi, vi->xattr_shared_xattrs[i]);
it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]);
- if (!i || blkaddr != it->it.blkaddr) {
- if (i)
- xattr_iter_end(&it->it, true);
-
- it->it.page = erofs_get_meta_page(sb, blkaddr);
- if (IS_ERR(it->it.page))
- return PTR_ERR(it->it.page);
-
- it->it.kaddr = kmap_atomic(it->it.page);
- it->it.blkaddr = blkaddr;
- }
+ it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
+ EROFS_KMAP_ATOMIC);
+ if (IS_ERR(it->it.kaddr))
+ return PTR_ERR(it->it.kaddr);
+ it->it.blkaddr = blkaddr;
ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
if (ret)
break;
}
- if (vi->xattr_shared_count)
- xattr_iter_end_final(&it->it);
-
return ret ? ret : it->buffer_ofs;
}
@@ -659,6 +603,7 @@ ssize_t erofs_listxattr(struct dentry *dentry,
if (ret)
return ret;
+ it.it.buf = __EROFS_BUF_INITIALIZER;
it.dentry = dentry;
it.buffer = buffer;
it.buffer_size = buffer_size;
@@ -667,9 +612,10 @@ ssize_t erofs_listxattr(struct dentry *dentry,
it.it.sb = dentry->d_sb;
ret = inline_listxattr(&it);
- if (ret < 0 && ret != -ENOATTR)
- return ret;
- return shared_listxattr(&it);
+ if (ret >= 0 || ret == -ENOATTR)
+ ret = shared_listxattr(&it);
+ erofs_put_metabuf(&it.it.buf);
+ return ret;
}
#ifdef CONFIG_EROFS_FS_POSIX_ACL
--
2.24.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-11 0:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 0:26 [PATCH v2 4/5] erofs: use meta buffers for xattr operations kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-01-02 4:00 [PATCH v2 0/5] erofs: get rid of erofs_get_meta_page() Gao Xiang
2022-01-02 4:00 ` [PATCH v2 4/5] erofs: use meta buffers for xattr operations Gao Xiang
2022-01-02 4:00 ` Gao Xiang
2022-01-02 7:48 ` Liu Bo
2022-01-02 7:48 ` Liu Bo
2022-01-04 8:07 ` Chao Yu
2022-01-04 8:07 ` Chao Yu
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.