Lines Matching refs:it
18 static inline void xattr_iter_end(struct xattr_iter *it, bool atomic) in xattr_iter_end() argument
22 kunmap(it->page); in xattr_iter_end()
24 kunmap_atomic(it->kaddr); in xattr_iter_end()
26 unlock_page(it->page); in xattr_iter_end()
27 put_page(it->page); in xattr_iter_end()
30 static inline void xattr_iter_end_final(struct xattr_iter *it) in xattr_iter_end_final() argument
32 if (!it->page) in xattr_iter_end_final()
35 xattr_iter_end(it, true); in xattr_iter_end_final()
41 struct xattr_iter it; in init_inode_xattrs() local
94 it.blkaddr = erofs_blknr(iloc(sbi, vi->nid) + vi->inode_isize); in init_inode_xattrs()
95 it.ofs = erofs_blkoff(iloc(sbi, vi->nid) + vi->inode_isize); in init_inode_xattrs()
97 it.page = erofs_get_meta_page(sb, it.blkaddr); in init_inode_xattrs()
98 if (IS_ERR(it.page)) { in init_inode_xattrs()
99 ret = PTR_ERR(it.page); in init_inode_xattrs()
104 it.kaddr = kmap(it.page); in init_inode_xattrs()
107 ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs); in init_inode_xattrs()
113 xattr_iter_end(&it, atomic_map); in init_inode_xattrs()
119 it.ofs += sizeof(struct erofs_xattr_ibody_header); in init_inode_xattrs()
122 if (it.ofs >= EROFS_BLKSIZ) { in init_inode_xattrs()
124 DBG_BUGON(it.ofs != EROFS_BLKSIZ); in init_inode_xattrs()
125 xattr_iter_end(&it, atomic_map); in init_inode_xattrs()
127 it.page = erofs_get_meta_page(sb, ++it.blkaddr); in init_inode_xattrs()
128 if (IS_ERR(it.page)) { in init_inode_xattrs()
131 ret = PTR_ERR(it.page); in init_inode_xattrs()
135 it.kaddr = kmap_atomic(it.page); in init_inode_xattrs()
137 it.ofs = 0; in init_inode_xattrs()
140 le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs)); in init_inode_xattrs()
141 it.ofs += sizeof(__le32); in init_inode_xattrs()
143 xattr_iter_end(&it, atomic_map); in init_inode_xattrs()
170 static inline int xattr_iter_fixup(struct xattr_iter *it) in xattr_iter_fixup() argument
172 if (it->ofs < EROFS_BLKSIZ) in xattr_iter_fixup()
175 xattr_iter_end(it, true); in xattr_iter_fixup()
177 it->blkaddr += erofs_blknr(it->ofs); in xattr_iter_fixup()
179 it->page = erofs_get_meta_page(it->sb, it->blkaddr); in xattr_iter_fixup()
180 if (IS_ERR(it->page)) { in xattr_iter_fixup()
181 int err = PTR_ERR(it->page); in xattr_iter_fixup()
183 it->page = NULL; in xattr_iter_fixup()
187 it->kaddr = kmap_atomic(it->page); in xattr_iter_fixup()
188 it->ofs = erofs_blkoff(it->ofs); in xattr_iter_fixup()
192 static int inline_xattr_iter_begin(struct xattr_iter *it, in inline_xattr_iter_begin() argument
207 it->blkaddr = erofs_blknr(iloc(sbi, vi->nid) + inline_xattr_ofs); in inline_xattr_iter_begin()
208 it->ofs = erofs_blkoff(iloc(sbi, vi->nid) + inline_xattr_ofs); in inline_xattr_iter_begin()
210 it->page = erofs_get_meta_page(inode->i_sb, it->blkaddr); in inline_xattr_iter_begin()
211 if (IS_ERR(it->page)) in inline_xattr_iter_begin()
212 return PTR_ERR(it->page); in inline_xattr_iter_begin()
214 it->kaddr = kmap_atomic(it->page); in inline_xattr_iter_begin()
222 static int xattr_foreach(struct xattr_iter *it, in xattr_foreach() argument
231 err = xattr_iter_fixup(it); in xattr_foreach()
240 entry = *(struct erofs_xattr_entry *)(it->kaddr + it->ofs); in xattr_foreach()
252 it->ofs += sizeof(struct erofs_xattr_entry); in xattr_foreach()
256 err = op->entry(it, &entry); in xattr_foreach()
258 it->ofs += entry.e_name_len + value_sz; in xattr_foreach()
266 if (it->ofs >= EROFS_BLKSIZ) { in xattr_foreach()
267 DBG_BUGON(it->ofs > EROFS_BLKSIZ); in xattr_foreach()
269 err = xattr_iter_fixup(it); in xattr_foreach()
272 it->ofs = 0; in xattr_foreach()
275 slice = min_t(unsigned int, PAGE_SIZE - it->ofs, in xattr_foreach()
279 err = op->name(it, processed, it->kaddr + it->ofs, slice); in xattr_foreach()
281 it->ofs += entry.e_name_len - processed + value_sz; in xattr_foreach()
285 it->ofs += slice; in xattr_foreach()
293 err = op->alloc_buffer(it, value_sz); in xattr_foreach()
295 it->ofs += value_sz; in xattr_foreach()
301 if (it->ofs >= EROFS_BLKSIZ) { in xattr_foreach()
302 DBG_BUGON(it->ofs > EROFS_BLKSIZ); in xattr_foreach()
304 err = xattr_iter_fixup(it); in xattr_foreach()
307 it->ofs = 0; in xattr_foreach()
310 slice = min_t(unsigned int, PAGE_SIZE - it->ofs, in xattr_foreach()
312 op->value(it, processed, it->kaddr + it->ofs, slice); in xattr_foreach()
313 it->ofs += slice; in xattr_foreach()
319 it->ofs = EROFS_XATTR_ALIGN(it->ofs); in xattr_foreach()
324 struct xattr_iter it; member
334 struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); in xattr_entrymatch() local
336 return (it->index != entry->e_name_index || in xattr_entrymatch()
337 it->name.len != entry->e_name_len) ? -ENOATTR : 0; in xattr_entrymatch()
343 struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); in xattr_namematch() local
345 return memcmp(buf, it->name.name + processed, len) ? -ENOATTR : 0; in xattr_namematch()
351 struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); in xattr_checkbuffer() local
352 int err = it->buffer_size < value_sz ? -ERANGE : 0; in xattr_checkbuffer()
354 it->buffer_size = value_sz; in xattr_checkbuffer()
355 return !it->buffer ? 1 : err; in xattr_checkbuffer()
362 struct getxattr_iter *it = container_of(_it, struct getxattr_iter, it); in xattr_copyvalue() local
364 memcpy(it->buffer + processed, buf, len); in xattr_copyvalue()
374 static int inline_getxattr(struct inode *inode, struct getxattr_iter *it) in inline_getxattr() argument
379 ret = inline_xattr_iter_begin(&it->it, inode); in inline_getxattr()
385 ret = xattr_foreach(&it->it, &find_xattr_handlers, &remaining); in inline_getxattr()
389 xattr_iter_end_final(&it->it); in inline_getxattr()
391 return ret ? ret : it->buffer_size; in inline_getxattr()
394 static int shared_getxattr(struct inode *inode, struct getxattr_iter *it) in shared_getxattr() argument
406 it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); in shared_getxattr()
408 if (!i || blkaddr != it->it.blkaddr) { in shared_getxattr()
410 xattr_iter_end(&it->it, true); in shared_getxattr()
412 it->it.page = erofs_get_meta_page(sb, blkaddr); in shared_getxattr()
413 if (IS_ERR(it->it.page)) in shared_getxattr()
414 return PTR_ERR(it->it.page); in shared_getxattr()
416 it->it.kaddr = kmap_atomic(it->it.page); in shared_getxattr()
417 it->it.blkaddr = blkaddr; in shared_getxattr()
420 ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL); in shared_getxattr()
425 xattr_iter_end_final(&it->it); in shared_getxattr()
427 return ret ? ret : it->buffer_size; in shared_getxattr()
445 struct getxattr_iter it; in erofs_getxattr() local
454 it.index = index; in erofs_getxattr()
456 it.name.len = strlen(name); in erofs_getxattr()
457 if (it.name.len > EROFS_NAME_LEN) in erofs_getxattr()
459 it.name.name = name; in erofs_getxattr()
461 it.buffer = buffer; in erofs_getxattr()
462 it.buffer_size = buffer_size; in erofs_getxattr()
464 it.it.sb = inode->i_sb; in erofs_getxattr()
465 ret = inline_getxattr(inode, &it); in erofs_getxattr()
467 ret = shared_getxattr(inode, &it); in erofs_getxattr()
529 struct xattr_iter it; member
539 struct listxattr_iter *it = in xattr_entrylist() local
540 container_of(_it, struct listxattr_iter, it); in xattr_entrylist()
547 if (!h || (h->list && !h->list(it->dentry))) in xattr_entrylist()
553 if (!it->buffer) { in xattr_entrylist()
554 it->buffer_ofs += prefix_len + entry->e_name_len + 1; in xattr_entrylist()
558 if (it->buffer_ofs + prefix_len in xattr_entrylist()
559 + entry->e_name_len + 1 > it->buffer_size) in xattr_entrylist()
562 memcpy(it->buffer + it->buffer_ofs, prefix, prefix_len); in xattr_entrylist()
563 it->buffer_ofs += prefix_len; in xattr_entrylist()
570 struct listxattr_iter *it = in xattr_namelist() local
571 container_of(_it, struct listxattr_iter, it); in xattr_namelist()
573 memcpy(it->buffer + it->buffer_ofs, buf, len); in xattr_namelist()
574 it->buffer_ofs += len; in xattr_namelist()
581 struct listxattr_iter *it = in xattr_skipvalue() local
582 container_of(_it, struct listxattr_iter, it); in xattr_skipvalue()
584 it->buffer[it->buffer_ofs++] = '\0'; in xattr_skipvalue()
595 static int inline_listxattr(struct listxattr_iter *it) in inline_listxattr() argument
600 ret = inline_xattr_iter_begin(&it->it, d_inode(it->dentry)); in inline_listxattr()
606 ret = xattr_foreach(&it->it, &list_xattr_handlers, &remaining); in inline_listxattr()
610 xattr_iter_end_final(&it->it); in inline_listxattr()
611 return ret ? ret : it->buffer_ofs; in inline_listxattr()
614 static int shared_listxattr(struct listxattr_iter *it) in shared_listxattr() argument
616 struct inode *const inode = d_inode(it->dentry); in shared_listxattr()
627 it->it.ofs = xattrblock_offset(sbi, vi->xattr_shared_xattrs[i]); in shared_listxattr()
628 if (!i || blkaddr != it->it.blkaddr) { in shared_listxattr()
630 xattr_iter_end(&it->it, true); in shared_listxattr()
632 it->it.page = erofs_get_meta_page(sb, blkaddr); in shared_listxattr()
633 if (IS_ERR(it->it.page)) in shared_listxattr()
634 return PTR_ERR(it->it.page); in shared_listxattr()
636 it->it.kaddr = kmap_atomic(it->it.page); in shared_listxattr()
637 it->it.blkaddr = blkaddr; in shared_listxattr()
640 ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL); in shared_listxattr()
645 xattr_iter_end_final(&it->it); in shared_listxattr()
647 return ret ? ret : it->buffer_ofs; in shared_listxattr()
654 struct listxattr_iter it; in erofs_listxattr() local
662 it.dentry = dentry; in erofs_listxattr()
663 it.buffer = buffer; in erofs_listxattr()
664 it.buffer_size = buffer_size; in erofs_listxattr()
665 it.buffer_ofs = 0; in erofs_listxattr()
667 it.it.sb = dentry->d_sb; in erofs_listxattr()
669 ret = inline_listxattr(&it); in erofs_listxattr()
672 return shared_listxattr(&it); in erofs_listxattr()