reiserfs: add comment to explain endianness issue in xattr_hash
[sfrench/cifs-2.6.git] / fs / reiserfs / xattr.c
index 48cdfc81fe10641da6025849c27d8f307f968a50..b5b26d8a192c4ae71d5a958bd4968183f3ca010a 100644 (file)
@@ -185,6 +185,7 @@ struct reiserfs_dentry_buf {
        struct dir_context ctx;
        struct dentry *xadir;
        int count;
+       int err;
        struct dentry *dentries[8];
 };
 
@@ -207,6 +208,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
 
        dentry = lookup_one_len(name, dbuf->xadir, namelen);
        if (IS_ERR(dentry)) {
+               dbuf->err = PTR_ERR(dentry);
                return PTR_ERR(dentry);
        } else if (d_really_is_negative(dentry)) {
                /* A directory entry exists, but no file? */
@@ -215,6 +217,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
                               "not found for file %pd.\n",
                               dentry, dbuf->xadir);
                dput(dentry);
+               dbuf->err = -EIO;
                return -EIO;
        }
 
@@ -262,6 +265,10 @@ static int reiserfs_for_each_xattr(struct inode *inode,
                err = reiserfs_readdir_inode(d_inode(dir), &buf.ctx);
                if (err)
                        break;
+               if (buf.err) {
+                       err = buf.err;
+                       break;
+               }
                if (!buf.count)
                        break;
                for (i = 0; !err && i < buf.count && buf.dentries[i]; i++) {
@@ -443,6 +450,15 @@ fail:
 
 static inline __u32 xattr_hash(const char *msg, int len)
 {
+       /*
+        * csum_partial() gives different results for little-endian and
+        * big endian hosts. Images created on little-endian hosts and
+        * mounted on big-endian hosts(and vice versa) will see csum mismatches
+        * when trying to fetch xattrs. Treating the hash as __wsum_t would
+        * lower the frequency of mismatch.  This is an endianness bug in
+        * reiserfs.  The return statement would result in a sparse warning. Do
+        * not fix the sparse warning so as to not hide a reminder of the bug.
+        */
        return csum_partial(msg, len, 0);
 }