f2fs: fix the use of XATTR_NODE_OFFSET
authorJaegeuk Kim <jaegeuk.kim@samsung.com>
Thu, 8 Aug 2013 23:14:06 +0000 (08:14 +0900)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Fri, 9 Aug 2013 05:57:56 +0000 (14:57 +0900)
This patch fixes the use of XATTR_NODE_OFFSET.

o The offset should not use several MSB bits which are used by marking node
blocks.

o IS_DNODE should handle XATTR_NODE_OFFSET to avoid potential abnormality
during the fsync call.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/f2fs.h
fs/f2fs/node.h

index d8e386ceb0cdeade11c5c08fcb95fd5379baa47d..eb8c45b65fe5e79ccef8a41d8d82a69b2582be2c 100644 (file)
@@ -135,11 +135,13 @@ static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
 /*
  * For INODE and NODE manager
  */
-#define XATTR_NODE_OFFSET      (-1)    /*
-                                        * store xattrs to one node block per
-                                        * file keeping -1 as its node offset to
-                                        * distinguish from index node blocks.
-                                        */
+/*
+ * XATTR_NODE_OFFSET stores xattrs to one node block per file keeping -1
+ * as its node offset to distinguish from index node blocks.
+ * But some bits are used to mark the node block.
+ */
+#define XATTR_NODE_OFFSET      ((((unsigned int)-1) << OFFSET_BIT_SHIFT) \
+                               >> OFFSET_BIT_SHIFT)
 enum {
        ALLOC_NODE,                     /* allocate a new node page if needed */
        LOOKUP_NODE,                    /* look up a node without readahead */
index 87349c4ea0ef4aa2e7d84cebfb33b9d82810be56..3496bb3e15dc37b7b6806dffc08a00abf5921766 100644 (file)
@@ -229,6 +229,10 @@ static inline block_t next_blkaddr_of_node(struct page *node_page)
 static inline bool IS_DNODE(struct page *node_page)
 {
        unsigned int ofs = ofs_of_node(node_page);
+
+       if (ofs == XATTR_NODE_OFFSET)
+               return false;
+
        if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
                        ofs == 5 + 2 * NIDS_PER_BLOCK)
                return false;
This page took 0.025727 seconds and 5 git commands to generate.