From 8dee30047c6b09c9920b91844db86960e4e6c502 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 10 Oct 2017 15:58:29 -0700 Subject: [PATCH] scoutfs: fix xattr trans reservation The xattr trans reservation assumed that it was only dirtying items for the new xattr size. It didn't account for dirty deletion items for parts from a larger previous xattr. With this fixed generic/070 no longer triggers warnings. Signed-off-by: Zach Brown --- kmod/src/count.h | 23 +++++++++++++---------- kmod/src/xattr.c | 1 - 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/kmod/src/count.h b/kmod/src/count.h index 5a11f127..fedeba69 100644 --- a/kmod/src/count.h +++ b/kmod/src/count.h @@ -183,24 +183,27 @@ static inline const struct scoutfs_item_count SIC_RENAME(unsigned old_len, } /* - * Setting an xattr can create a full set of items for an xattr with a - * max name and length. Any existing items will be dirtied rather than - * deleted so we won't have more items than a max xattr's worth. + * Setting an xattr results in a dirty set of items with values for the + * size of the xattr. Any previously existing items from a larger xattr + * are deleted which dirties their key but removes their value. We + * don't know the size of a possibly existing xattr so we assume max + * parts. */ static inline const struct scoutfs_item_count SIC_XATTR_SET(unsigned name_len, unsigned size) { struct scoutfs_item_count cnt = {0,}; - unsigned parts = DIV_ROUND_UP(size, SCOUTFS_XATTR_PART_SIZE); + unsigned val_parts = DIV_ROUND_UP(size, SCOUTFS_XATTR_PART_SIZE); __count_dirty_inode(&cnt); - cnt.items += parts; - cnt.keys += parts * (offsetof(struct scoutfs_xattr_key, - name[name_len]) + - sizeof(struct scoutfs_xattr_key_footer)); - cnt.vals += parts * (sizeof(struct scoutfs_xattr_val_header) + - SCOUTFS_XATTR_PART_SIZE); + cnt.items += SCOUTFS_XATTR_MAX_PARTS; + cnt.keys += SCOUTFS_XATTR_MAX_PARTS * + (offsetof(struct scoutfs_xattr_key, name[name_len]) + + sizeof(struct scoutfs_xattr_key_footer)); + cnt.vals += val_parts * + (sizeof(struct scoutfs_xattr_val_header) + + SCOUTFS_XATTR_PART_SIZE); return cnt; } diff --git a/kmod/src/xattr.c b/kmod/src/xattr.c index 20978835..5f7a1415 100644 --- a/kmod/src/xattr.c +++ b/kmod/src/xattr.c @@ -252,7 +252,6 @@ out: * another. */ static int scoutfs_xattr_set(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) {