]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
hfsplus: split up inode flags
authorChristoph Hellwig <hch@tuxera.com>
Tue, 23 Nov 2010 13:38:13 +0000 (14:38 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 23 Nov 2010 13:38:13 +0000 (14:38 +0100)
Split the flags field in the hfsplus inode into an extent_state
flag that is locked by the extent_lock, and a new flags field
that uses atomic bitops.  The second will grow more flags in the
next patch.

Signed-off-by: Christoph Hellwig <hch@tuxera.com>
fs/hfsplus/extents.c
fs/hfsplus/hfsplus_fs.h
fs/hfsplus/inode.c
fs/hfsplus/super.c

index 0c9cb1820a523fae02c6bf2f37e6fbdc5c5dceeb..06b4fc3151a39c9a165e72c242ce7ed323093b74 100644 (file)
@@ -95,24 +95,24 @@ static void __hfsplus_ext_write_extent(struct inode *inode, struct hfs_find_data
                                HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA);
 
        res = hfs_brec_find(fd);
-       if (hip->flags & HFSPLUS_FLG_EXT_NEW) {
+       if (hip->extent_state & HFSPLUS_EXT_NEW) {
                if (res != -ENOENT)
                        return;
                hfs_brec_insert(fd, hip->cached_extents,
                                sizeof(hfsplus_extent_rec));
-               hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
+               hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
        } else {
                if (res)
                        return;
                hfs_bnode_write(fd->bnode, hip->cached_extents,
                                fd->entryoffset, fd->entrylength);
-               hip->flags &= ~HFSPLUS_FLG_EXT_DIRTY;
+               hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
        }
 }
 
 static void hfsplus_ext_write_extent_locked(struct inode *inode)
 {
-       if (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_EXT_DIRTY) {
+       if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
                struct hfs_find_data fd;
 
                hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
@@ -155,7 +155,7 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct in
 
        WARN_ON(!mutex_is_locked(&hip->extents_lock));
 
-       if (hip->flags & HFSPLUS_FLG_EXT_DIRTY)
+       if (hip->extent_state & HFSPLUS_EXT_DIRTY)
                __hfsplus_ext_write_extent(inode, fd);
 
        res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
@@ -167,7 +167,7 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct in
                hip->cached_blocks = hfsplus_ext_block_count(hip->cached_extents);
        } else {
                hip->cached_start = hip->cached_blocks = 0;
-               hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
+               hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
        }
        return res;
 }
@@ -429,7 +429,7 @@ int hfsplus_file_extend(struct inode *inode)
                                         start, len);
                if (!res) {
                        hfsplus_dump_extent(hip->cached_extents);
-                       hip->flags |= HFSPLUS_FLG_EXT_DIRTY;
+                       hip->extent_state |= HFSPLUS_EXT_DIRTY;
                        hip->cached_blocks += len;
                } else if (res == -ENOSPC)
                        goto insert_extent;
@@ -450,7 +450,7 @@ insert_extent:
        hip->cached_extents[0].start_block = cpu_to_be32(start);
        hip->cached_extents[0].block_count = cpu_to_be32(len);
        hfsplus_dump_extent(hip->cached_extents);
-       hip->flags |= HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW;
+       hip->extent_state |= HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW;
        hip->cached_start = hip->alloc_blocks;
        hip->cached_blocks = len;
 
@@ -513,12 +513,12 @@ void hfsplus_file_truncate(struct inode *inode)
                                     alloc_cnt - start, alloc_cnt - blk_cnt);
                hfsplus_dump_extent(hip->cached_extents);
                if (blk_cnt > start) {
-                       hip->flags |= HFSPLUS_FLG_EXT_DIRTY;
+                       hip->extent_state |= HFSPLUS_EXT_DIRTY;
                        break;
                }
                alloc_cnt = start;
                hip->cached_start = hip->cached_blocks = 0;
-               hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
+               hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
                hfs_brec_remove(&fd);
        }
        hfs_find_exit(&fd);
index 625549579e9ea430eed35aaefc396e80bf2f0536..9889d0033b8f3821d670877c59497cdbc15d8eae 100644 (file)
@@ -171,7 +171,7 @@ struct hfsplus_inode_info {
        u32 cached_blocks;
        hfsplus_extent_rec first_extents;
        hfsplus_extent_rec cached_extents;
-       unsigned long flags;
+       unsigned int extent_state;
        struct mutex extents_lock;
 
        /*
@@ -185,6 +185,11 @@ struct hfsplus_inode_info {
         */
        u32 linkid;
 
+       /*
+        * Accessed using atomic bitops.
+        */
+       unsigned long flags;
+
        /*
         * Protected by i_mutex.
         */
@@ -196,12 +201,13 @@ struct hfsplus_inode_info {
        struct inode vfs_inode;
 };
 
-#define HFSPLUS_FLG_RSRC       0x0001
-#define HFSPLUS_FLG_EXT_DIRTY  0x0002
-#define HFSPLUS_FLG_EXT_NEW    0x0004
+#define HFSPLUS_EXT_DIRTY      0x0001
+#define HFSPLUS_EXT_NEW                0x0002
+
+#define HFSPLUS_I_RSRC         0       /* represents a resource fork */
 
-#define HFSPLUS_IS_DATA(inode)   (!(HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC))
-#define HFSPLUS_IS_RSRC(inode)   (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC)
+#define HFSPLUS_IS_RSRC(inode) \
+       test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
 
 struct hfs_find_data {
        /* filled by caller */
index 8cd8dc2e7fdd87fbea5845c441876dd3e481c1ba..0946e2cdca5e9ac03547b1dcb0543e3d3167e477 100644 (file)
@@ -190,7 +190,9 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
        inode->i_ino = dir->i_ino;
        INIT_LIST_HEAD(&hip->open_dir_list);
        mutex_init(&hip->extents_lock);
-       hip->flags = HFSPLUS_FLG_RSRC;
+       hip->extent_state = 0;
+       hip->flags = 0;
+       set_bit(HFSPLUS_I_RSRC, &hip->flags);
 
        hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
        err = hfsplus_find_cat(sb, dir->i_ino, &fd);
@@ -369,6 +371,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
        INIT_LIST_HEAD(&hip->open_dir_list);
        mutex_init(&hip->extents_lock);
        atomic_set(&hip->opencnt, 0);
+       hip->extent_state = 0;
        hip->flags = 0;
        memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
        memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
@@ -498,8 +501,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
                hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
                                        sizeof(struct hfsplus_cat_file));
 
-               hfsplus_inode_read_fork(inode, HFSPLUS_IS_DATA(inode) ?
-                                       &file->data_fork : &file->rsrc_fork);
+               hfsplus_inode_read_fork(inode, HFSPLUS_IS_RSRC(inode) ?
+                                       &file->rsrc_fork : &file->data_fork);
                hfsplus_get_perms(inode, &file->permissions, 0);
                inode->i_nlink = 1;
                if (S_ISREG(inode->i_mode)) {
index 56e6cf80c5e07d810a86d7a59785d42cc9371cd3..985423728e1d1bbc1e9bbc6e1ead6ae293f6dd50 100644 (file)
@@ -66,6 +66,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
        INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list);
        mutex_init(&HFSPLUS_I(inode)->extents_lock);
        HFSPLUS_I(inode)->flags = 0;
+       HFSPLUS_I(inode)->extent_state = 0;
        HFSPLUS_I(inode)->rsrc_inode = NULL;
        atomic_set(&HFSPLUS_I(inode)->opencnt, 0);