fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / reiserfs / inode.c
index 52a9e2a..36b8abd 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/writeback.h>
 #include <linux/quotaops.h>
 #include <linux/vs_dlimit.h>
-#include <linux/vserver/xid.h>
+#include <linux/vs_tag.h>
 
 static int reiserfs_commit_write(struct file *f, struct page *page,
                                 unsigned from, unsigned to);
@@ -210,7 +210,7 @@ static int file_capable(struct inode *inode, long block)
 }
 
 /*static*/ int restart_transaction(struct reiserfs_transaction_handle *th,
-                                  struct inode *inode, struct path *path)
+                                  struct inode *inode, struct treepath *path)
 {
        struct super_block *s = th->t_super;
        int len = th->t_blocks_allocated;
@@ -219,11 +219,12 @@ static int file_capable(struct inode *inode, long block)
        BUG_ON(!th->t_trans_id);
        BUG_ON(!th->t_refcount);
 
+       pathrelse(path);
+
        /* we cannot restart while nested */
        if (th->t_refcount > 1) {
                return 0;
        }
-       pathrelse(path);
        reiserfs_update_sd(th, inode);
        err = journal_end(th, s, len);
        if (!err) {
@@ -572,7 +573,7 @@ static inline int _allocate_block(struct reiserfs_transaction_handle *th,
                                  long block,
                                  struct inode *inode,
                                  b_blocknr_t * allocated_block_nr,
-                                 struct path *path, int flags)
+                                 struct treepath *path, int flags)
 {
        BUG_ON(!th->t_trans_id);
 
@@ -931,15 +932,12 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
                        if (blocks_needed == 1) {
                                un = &unf_single;
                        } else {
-                               un = kmalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC);      // We need to avoid scheduling.
+                               un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC);      // We need to avoid scheduling.
                                if (!un) {
                                        un = &unf_single;
                                        blocks_needed = 1;
                                        max_to_insert = 0;
-                               } else
-                                       memset(un, 0,
-                                              UNFM_P_SIZE * min(blocks_needed,
-                                                                max_to_insert));
+                               }
                        }
                        if (blocks_needed <= max_to_insert) {
                                /* we are going to add target block to the file. Use allocated
@@ -1112,7 +1110,7 @@ static inline ulong to_fake_used_blocks(struct inode *inode, int sd_size)
 //
 
 // called by read_locked_inode
-static void init_inode(struct inode *inode, struct path *path)
+static void init_inode(struct inode *inode, struct treepath *path)
 {
        struct buffer_head *bh;
        struct item_head *ih;
@@ -1132,9 +1130,10 @@ static void init_inode(struct inode *inode, struct path *path)
        REISERFS_I(inode)->i_prealloc_count = 0;
        REISERFS_I(inode)->i_trans_id = 0;
        REISERFS_I(inode)->i_jl = NULL;
-       REISERFS_I(inode)->i_acl_access = NULL;
-       REISERFS_I(inode)->i_acl_default = NULL;
-       init_rwsem(&REISERFS_I(inode)->xattr_sem);
+       mutex_init(&(REISERFS_I(inode)->i_mmap));
+       reiserfs_init_acl_access(inode);
+       reiserfs_init_acl_default(inode);
+       reiserfs_init_xattr_rwsem(inode);
 
        if (stat_data_v1(ih)) {
                struct stat_data_v1 *sd =
@@ -1224,9 +1223,9 @@ static void init_inode(struct inode *inode, struct path *path)
                sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
        }
 
-       inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
-       inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
-       inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid, 0);
+       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
+       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
+       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
 
        pathrelse(path);
        if (S_ISREG(inode->i_mode)) {
@@ -1250,8 +1249,8 @@ static void init_inode(struct inode *inode, struct path *path)
 static void inode2sd(void *sd, struct inode *inode, loff_t size)
 {
        struct stat_data *sd_v2 = (struct stat_data *)sd;
-       uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
-       gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
+       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
+       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
        __u16 flags;
 
        set_sd_v2_uid(sd_v2, uid);
@@ -1299,7 +1298,7 @@ static void inode2sd_v1(void *sd, struct inode *inode, loff_t size)
 /* NOTE, you must prepare the buffer head before sending it here,
 ** and then log it after the call
 */
-static void update_stat_data(struct path *path, struct inode *inode,
+static void update_stat_data(struct treepath *path, struct inode *inode,
                             loff_t size)
 {
        struct buffer_head *bh;
@@ -1668,7 +1667,7 @@ int reiserfs_write_inode(struct inode *inode, int do_sync)
    containing "." and ".." entries */
 static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
                                  struct inode *inode,
-                                 struct item_head *ih, struct path *path,
+                                 struct item_head *ih, struct treepath *path,
                                  struct inode *dir)
 {
        struct super_block *sb = th->t_super;
@@ -1727,7 +1726,7 @@ static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
    containing the body of symlink */
 static int reiserfs_new_symlink(struct reiserfs_transaction_handle *th, struct inode *inode,   /* Inode of symlink */
                                struct item_head *ih,
-                               struct path *path, const char *symname,
+                               struct treepath *path, const char *symname,
                                int item_len)
 {
        struct super_block *sb = th->t_super;
@@ -1797,7 +1796,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
                err = -EDQUOT;
                goto out_end_trans;
        }
-       if (!dir || !dir->i_nlink) {
+       if (!dir->i_nlink) {
                err = -EPERM;
                goto out_bad_inode;
        }
@@ -1851,9 +1850,10 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
        REISERFS_I(inode)->i_attrs =
            REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK;
        sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode);
-       REISERFS_I(inode)->i_acl_access = NULL;
-       REISERFS_I(inode)->i_acl_default = NULL;
-       init_rwsem(&REISERFS_I(inode)->xattr_sem);
+       mutex_init(&(REISERFS_I(inode)->i_mmap));
+       reiserfs_init_acl_access(inode);
+       reiserfs_init_acl_default(inode);
+       reiserfs_init_xattr_rwsem(inode);
 
        if (old_format_only(sb))
                make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
@@ -1994,11 +1994,13 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
         * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
         * code really needs to be reworked, but this will take care of it
         * for now. -jeffm */
+#ifdef CONFIG_REISERFS_FS_POSIX_ACL
        if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) {
                reiserfs_write_unlock_xattrs(dir->i_sb);
                iput(inode);
                reiserfs_write_lock_xattrs(dir->i_sb);
        } else
+#endif
                iput(inode);
        return err;
 }
@@ -2360,7 +2362,7 @@ static int reiserfs_write_full_page(struct page *page,
        struct buffer_head *head, *bh;
        int partial = 0;
        int nr = 0;
-       int checked = PageFsMisc(page);
+       int checked = PageChecked(page);
        struct reiserfs_transaction_handle th;
        struct super_block *s = inode->i_sb;
        int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
@@ -2438,7 +2440,7 @@ static int reiserfs_write_full_page(struct page *page,
         * blocks we're going to log
         */
        if (checked) {
-               ClearPageFsMisc(page);
+               ClearPageChecked(page);
                reiserfs_write_lock(s);
                error = journal_begin(&th, s, bh_per_page + 1);
                if (error) {
@@ -2835,7 +2837,7 @@ static void reiserfs_invalidatepage(struct page *page, unsigned long offset)
        BUG_ON(!PageLocked(page));
 
        if (offset == 0)
-               ClearPageFsMisc(page);
+               ClearPageChecked(page);
 
        if (!page_has_buffers(page))
                goto out;
@@ -2876,7 +2878,7 @@ static int reiserfs_set_page_dirty(struct page *page)
 {
        struct inode *inode = page->mapping->host;
        if (reiserfs_file_data_log(inode)) {
-               SetPageFsMisc(page);
+               SetPageChecked(page);
                return __set_page_dirty_nobuffers(page);
        }
        return __set_page_dirty_buffers(page);
@@ -2899,7 +2901,7 @@ static int reiserfs_releasepage(struct page *page, gfp_t unused_gfp_flags)
        struct buffer_head *bh;
        int ret = 1;
 
-       WARN_ON(PageFsMisc(page));
+       WARN_ON(PageChecked(page));
        spin_lock(&j->j_dirty_buffers_lock);
        head = page_buffers(page);
        bh = head;
@@ -3003,7 +3005,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
        if (!error) {
                if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
                    (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
-                   (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid)) {
+                   (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
                        error = reiserfs_chown_xattrs(inode, attr);
 
                        if (!error) {
@@ -3033,9 +3035,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
                                        inode->i_uid = attr->ia_uid;
                                if (attr->ia_valid & ATTR_GID)
                                        inode->i_gid = attr->ia_gid;
-                               if ((attr->ia_valid & ATTR_XID) &&
-                                       IS_TAGXID(inode))
-                                       inode->i_xid = attr->ia_xid;
+                               if ((attr->ia_valid & ATTR_TAG) &&
+                                       IS_TAGGED(inode))
+                                       inode->i_tag = attr->ia_tag;
                                mark_inode_dirty(inode);
                                error =
                                    journal_end(&th, inode->i_sb, jbegin_count);