diff options
| author | Kinglong Mee <kinglongmee@gmail.com> | 2017-02-25 19:23:27 +0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:35:03 +0200 |
| commit | e673f802969d5aa4c9b733b414d8e25032f22301 (patch) | |
| tree | f2a00f074e6862559bf315eb0ee1ce8df1c172e2 | |
| parent | 514d121e46bc11605edbf0bbf427b5baabfa9933 (diff) | |
f2fs: Don't update the xattr data that same as the exist
f2fs removes the old xattr data and appends the new data although
the new data is same as the exist.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
| -rw-r--r-- | fs/f2fs/xattr.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 79251722b..fe99b8da7 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -586,6 +586,13 @@ cleanup: return error; } +static bool f2fs_xattr_value_same(struct f2fs_xattr_entry *entry, + const void *value, size_t size) +{ + void *pval = entry->e_name + entry->e_name_len; + return (entry->e_value_size == size) && !memcmp(pval, value, size); +} + static int __f2fs_setxattr(struct inode *inode, int index, const char *name, const void *value, size_t size, struct page *ipage, int flags) @@ -620,12 +627,17 @@ static int __f2fs_setxattr(struct inode *inode, int index, found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1; - if ((flags & XATTR_REPLACE) && !found) { + if (found) { + if ((flags & XATTR_CREATE)) { + error = -EEXIST; + goto exit; + } + + if (f2fs_xattr_value_same(here, value, size)) + goto exit; + } else if ((flags & XATTR_REPLACE)) { error = -ENODATA; goto exit; - } else if ((flags & XATTR_CREATE) && found) { - error = -EEXIST; - goto exit; } last = here; |
