aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/xattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/xattr.c')
-rw-r--r--fs/reiserfs/xattr.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 821bcf70e467..c69cdd749f09 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -171,6 +171,7 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
171 * modifying extended attributes. This includes operations such as permissions 171 * modifying extended attributes. This includes operations such as permissions
172 * or ownership changes, object deletions, etc. */ 172 * or ownership changes, object deletions, etc. */
173struct reiserfs_dentry_buf { 173struct reiserfs_dentry_buf {
174 struct dir_context ctx;
174 struct dentry *xadir; 175 struct dentry *xadir;
175 int count; 176 int count;
176 struct dentry *dentries[8]; 177 struct dentry *dentries[8];
@@ -223,9 +224,8 @@ static int reiserfs_for_each_xattr(struct inode *inode,
223{ 224{
224 struct dentry *dir; 225 struct dentry *dir;
225 int i, err = 0; 226 int i, err = 0;
226 loff_t pos = 0;
227 struct reiserfs_dentry_buf buf = { 227 struct reiserfs_dentry_buf buf = {
228 .count = 0, 228 .ctx.actor = fill_with_dentries,
229 }; 229 };
230 230
231 /* Skip out, an xattr has no xattrs associated with it */ 231 /* Skip out, an xattr has no xattrs associated with it */
@@ -249,29 +249,27 @@ static int reiserfs_for_each_xattr(struct inode *inode,
249 reiserfs_write_lock(inode->i_sb); 249 reiserfs_write_lock(inode->i_sb);
250 250
251 buf.xadir = dir; 251 buf.xadir = dir;
252 err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); 252 while (1) {
253 while ((err == 0 || err == -ENOSPC) && buf.count) { 253 err = reiserfs_readdir_inode(dir->d_inode, &buf.ctx);
254 err = 0; 254 if (err)
255 255 break;
256 for (i = 0; i < buf.count && buf.dentries[i]; i++) { 256 if (!buf.count)
257 int lerr = 0; 257 break;
258 for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) {
258 struct dentry *dentry = buf.dentries[i]; 259 struct dentry *dentry = buf.dentries[i];
259 260
260 if (err == 0 && !S_ISDIR(dentry->d_inode->i_mode)) 261 if (!S_ISDIR(dentry->d_inode->i_mode))
261 lerr = action(dentry, data); 262 err = action(dentry, data);
262 263
263 dput(dentry); 264 dput(dentry);
264 buf.dentries[i] = NULL; 265 buf.dentries[i] = NULL;
265 err = lerr ?: err;
266 } 266 }
267 if (err)
268 break;
267 buf.count = 0; 269 buf.count = 0;
268 if (!err)
269 err = reiserfs_readdir_dentry(dir, &buf,
270 fill_with_dentries, &pos);
271 } 270 }
272 mutex_unlock(&dir->d_inode->i_mutex); 271 mutex_unlock(&dir->d_inode->i_mutex);
273 272
274 /* Clean up after a failed readdir */
275 cleanup_dentry_buf(&buf); 273 cleanup_dentry_buf(&buf);
276 274
277 if (!err) { 275 if (!err) {
@@ -800,6 +798,7 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name)
800} 798}
801 799
802struct listxattr_buf { 800struct listxattr_buf {
801 struct dir_context ctx;
803 size_t size; 802 size_t size;
804 size_t pos; 803 size_t pos;
805 char *buf; 804 char *buf;
@@ -845,8 +844,8 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
845{ 844{
846 struct dentry *dir; 845 struct dentry *dir;
847 int err = 0; 846 int err = 0;
848 loff_t pos = 0;
849 struct listxattr_buf buf = { 847 struct listxattr_buf buf = {
848 .ctx.actor = listxattr_filler,
850 .dentry = dentry, 849 .dentry = dentry,
851 .buf = buffer, 850 .buf = buffer,
852 .size = buffer ? size : 0, 851 .size = buffer ? size : 0,
@@ -868,7 +867,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
868 } 867 }
869 868
870 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); 869 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR);
871 err = reiserfs_readdir_dentry(dir, &buf, listxattr_filler, &pos); 870 err = reiserfs_readdir_inode(dir->d_inode, &buf.ctx);
872 mutex_unlock(&dir->d_inode->i_mutex); 871 mutex_unlock(&dir->d_inode->i_mutex);
873 872
874 if (!err) 873 if (!err)