fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / ocfs2 / inode.c
index 315472a..cea7429 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
+#include <linux/vs_tag.h>
 
 #include <asm/byteorder.h>
 
@@ -43,6 +44,7 @@
 #include "file.h"
 #include "heartbeat.h"
 #include "inode.h"
+#include "ioctl.h"
 #include "journal.h"
 #include "namei.h"
 #include "suballoc.h"
@@ -54,8 +56,6 @@
 
 #include "buffer_head_io.h"
 
-#define OCFS2_FI_FLAG_NOWAIT   0x1
-#define OCFS2_FI_FLAG_DELETE   0x2
 struct ocfs2_find_inode_args
 {
        u64             fi_blkno;
@@ -71,6 +71,51 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
                                    struct inode *inode,
                                    struct buffer_head *fe_bh);
 
+void ocfs2_set_inode_flags(struct inode *inode)
+{
+       unsigned int flags = OCFS2_I(inode)->ip_attr;
+
+       inode->i_flags &= ~(S_IMMUTABLE |
+               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
+
+       if (flags & OCFS2_IMMUTABLE_FL)
+               inode->i_flags |= S_IMMUTABLE;
+       if (flags & OCFS2_IUNLINK_FL)
+               inode->i_flags |= S_IUNLINK;
+       if (flags & OCFS2_BARRIER_FL)
+               inode->i_flags |= S_BARRIER;
+
+       if (flags & OCFS2_SYNC_FL)
+               inode->i_flags |= S_SYNC;
+       if (flags & OCFS2_APPEND_FL)
+               inode->i_flags |= S_APPEND;
+       if (flags & OCFS2_NOATIME_FL)
+               inode->i_flags |= S_NOATIME;
+       if (flags & OCFS2_DIRSYNC_FL)
+               inode->i_flags |= S_DIRSYNC;
+}
+
+int ocfs2_sync_flags(struct inode *inode)
+{
+       unsigned int oldflags, newflags;
+
+       oldflags = OCFS2_I(inode)->ip_flags;
+       newflags = oldflags & ~(OCFS2_IMMUTABLE_FL |
+               OCFS2_IUNLINK_FL | OCFS2_BARRIER_FL);
+
+       if (IS_IMMUTABLE(inode))
+               newflags |= OCFS2_IMMUTABLE_FL;
+       if (IS_IUNLINK(inode))
+               newflags |= OCFS2_IUNLINK_FL;
+       if (IS_BARRIER(inode))
+               newflags |= OCFS2_BARRIER_FL;
+
+       if (oldflags ^ newflags)
+               return ocfs2_set_inode_attr(inode,
+                       newflags, OCFS2_FL_MASK);
+       return 0;
+}
+
 struct inode *ocfs2_ilookup_for_vote(struct ocfs2_super *osb,
                                     u64 blkno,
                                     int delete_vote)
@@ -89,13 +134,13 @@ struct inode *ocfs2_ilookup_for_vote(struct ocfs2_super *osb,
        return ilookup5(osb->sb, args.fi_ino, ocfs2_find_actor, &args);
 }
 
-struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
+struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, int flags)
 {
        struct inode *inode = NULL;
        struct super_block *sb = osb->sb;
        struct ocfs2_find_inode_args args;
 
-       mlog_entry("(blkno = %"MLFu64")\n", blkno);
+       mlog_entry("(blkno = %llu)\n", (unsigned long long)blkno);
 
        /* Ok. By now we've either got the offsets passed to us by the
         * caller, or we just pulled them off the bh. Lets do some
@@ -107,7 +152,7 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
        }
 
        args.fi_blkno = blkno;
-       args.fi_flags = 0;
+       args.fi_flags = flags;
        args.fi_ino = ino_from_blkno(sb, blkno);
 
        inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor,
@@ -128,17 +173,15 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno)
        if (is_bad_inode(inode)) {
                iput(inode);
                inode = ERR_PTR(-ESTALE);
-               mlog_errno(PTR_ERR(inode));
                goto bail;
        }
 
 bail:
        if (!IS_ERR(inode)) {
-               mlog(0, "returning inode with number %"MLFu64"\n",
-                    OCFS2_I(inode)->ip_blkno);
+               mlog(0, "returning inode with number %llu\n",
+                    (unsigned long long)OCFS2_I(inode)->ip_blkno);
                mlog_exit_ptr(inode);
-       } else
-               mlog_errno(PTR_ERR(inode));
+       }
 
        return inode;
 }
@@ -218,8 +261,11 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
        struct super_block *sb;
        struct ocfs2_super *osb;
        int status = -EINVAL;
+       uid_t uid;
+       gid_t gid;
 
-       mlog_entry("(0x%p, size:%"MLFu64")\n", inode, fe->i_size);
+       mlog_entry("(0x%p, size:%llu)\n", inode,
+                  (unsigned long long)fe->i_size);
 
        sb = inode->i_sb;
        osb = OCFS2_SB(sb);
@@ -228,9 +274,10 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
         * today.  change if needed. */
        if (!OCFS2_IS_VALID_DINODE(fe) ||
            !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
-               mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%"MLFu64", "
+               mlog(0, "Invalid dinode: i_ino=%lu, i_blkno=%llu, "
                     "signature = %.*s, flags = 0x%x\n",
-                    inode->i_ino, le64_to_cpu(fe->i_blkno), 7,
+                    inode->i_ino,
+                    (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
                     fe->i_signature, le32_to_cpu(fe->i_flags));
                goto bail;
        }
@@ -247,9 +294,12 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
        inode->i_generation = le32_to_cpu(fe->i_generation);
        inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
        inode->i_mode = le16_to_cpu(fe->i_mode);
-       inode->i_uid = le32_to_cpu(fe->i_uid);
-       inode->i_gid = le32_to_cpu(fe->i_gid);
-       inode->i_blksize = (u32)osb->s_clustersize;
+       uid = le32_to_cpu(fe->i_uid);
+       gid = le32_to_cpu(fe->i_gid);
+       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,
+               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
 
        /* Fast symlinks will have i_size but no allocated clusters. */
        if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
@@ -258,7 +308,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
                inode->i_blocks =
                        ocfs2_align_bytes_to_sectors(le64_to_cpu(fe->i_size));
        inode->i_mapping->a_ops = &ocfs2_aops;
-       inode->i_flags |= S_NOATIME;
        inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime);
        inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec);
        inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime);
@@ -268,21 +317,19 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 
        if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno))
                mlog(ML_ERROR,
-                    "ip_blkno %"MLFu64" != i_blkno %"MLFu64"!\n",
-                    OCFS2_I(inode)->ip_blkno, fe->i_blkno);
+                    "ip_blkno %llu != i_blkno %llu!\n",
+                    (unsigned long long)OCFS2_I(inode)->ip_blkno,
+                    (unsigned long long)fe->i_blkno);
 
        OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
        OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT;
-
-       if (create_ino)
-               inode->i_ino = ino_from_blkno(inode->i_sb,
-                              le64_to_cpu(fe->i_blkno));
-
-       mlog(0, "blkno = %"MLFu64", ino = %lu, create_ino = %s\n",
-            fe->i_blkno, inode->i_ino, create_ino ? "true" : "false");
+       OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
 
        inode->i_nlink = le16_to_cpu(fe->i_links_count);
 
+       if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL))
+               OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE;
+
        if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) {
                OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
                mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino);
@@ -320,12 +367,30 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
                    break;
        }
 
+       if (create_ino) {
+               inode->i_ino = ino_from_blkno(inode->i_sb,
+                              le64_to_cpu(fe->i_blkno));
+
+               /*
+                * If we ever want to create system files from kernel,
+                * the generation argument to
+                * ocfs2_inode_lock_res_init() will have to change.
+                */
+               BUG_ON(fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL));
+
+               ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
+                                         OCFS2_LOCK_TYPE_META, 0, inode);
+       }
+
        ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_rw_lockres,
-                                 OCFS2_LOCK_TYPE_RW, inode);
-       ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
-                                 OCFS2_LOCK_TYPE_META, inode);
+                                 OCFS2_LOCK_TYPE_RW, inode->i_generation,
+                                 inode);
+
        ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres,
-                                 OCFS2_LOCK_TYPE_DATA, inode);
+                                 OCFS2_LOCK_TYPE_DATA, inode->i_generation,
+                                 inode);
+
+       ocfs2_set_inode_flags(inode);
 
        status = 0;
 bail:
@@ -340,15 +405,15 @@ static int ocfs2_read_locked_inode(struct inode *inode,
        struct ocfs2_super *osb;
        struct ocfs2_dinode *fe;
        struct buffer_head *bh = NULL;
-       int status;
-       int sysfile = 0;
+       int status, can_lock;
+       u32 generation = 0;
 
        mlog_entry("(0x%p, 0x%p)\n", inode, args);
 
        status = -EINVAL;
        if (inode == NULL || inode->i_sb == NULL) {
                mlog(ML_ERROR, "bad inode\n");
-               goto bail;
+               return status;
        }
        sb = inode->i_sb;
        osb = OCFS2_SB(sb);
@@ -356,50 +421,108 @@ static int ocfs2_read_locked_inode(struct inode *inode,
        if (!args) {
                mlog(ML_ERROR, "bad inode args\n");
                make_bad_inode(inode);
-               goto bail;
+               return status;
        }
 
-       /* Read the FE off disk. This is safe because the kernel only
-        * does one read_inode2 for a new inode, and if it doesn't
-        * exist yet then nobody can be working on it! */
-       status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0, NULL);
+       /*
+        * To improve performance of cold-cache inode stats, we take
+        * the cluster lock here if possible.
+        *
+        * Generally, OCFS2 never trusts the contents of an inode
+        * unless it's holding a cluster lock, so taking it here isn't
+        * a correctness issue as much as it is a performance
+        * improvement.
+        *
+        * There are three times when taking the lock is not a good idea:
+        *
+        * 1) During startup, before we have initialized the DLM.
+        *
+        * 2) If we are reading certain system files which never get
+        *    cluster locks (local alloc, truncate log).
+        *
+        * 3) If the process doing the iget() is responsible for
+        *    orphan dir recovery. We're holding the orphan dir lock and
+        *    can get into a deadlock with another process on another
+        *    node in ->delete_inode().
+        *
+        * #1 and #2 can be simply solved by never taking the lock
+        * here for system files (which are the only type we read
+        * during mount). It's a heavier approach, but our main
+        * concern is user-accesible files anyway.
+        *
+        * #3 works itself out because we'll eventually take the
+        * cluster lock before trusting anything anyway.
+        */
+       can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE)
+               && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK)
+               && !ocfs2_mount_local(osb);
+
+       /*
+        * To maintain backwards compatibility with older versions of
+        * ocfs2-tools, we still store the generation value for system
+        * files. The only ones that actually matter to userspace are
+        * the journals, but it's easier and inexpensive to just flag
+        * all system files similarly.
+        */
+       if (args->fi_flags & OCFS2_FI_FLAG_SYSFILE)
+               generation = osb->fs_generation;
+
+       ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres,
+                                 OCFS2_LOCK_TYPE_META,
+                                 generation, inode);
+
+       if (can_lock) {
+               status = ocfs2_meta_lock(inode, NULL, 0);
+               if (status) {
+                       make_bad_inode(inode);
+                       mlog_errno(status);
+                       return status;
+               }
+       }
+
+       status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0,
+                                 can_lock ? inode : NULL);
        if (status < 0) {
                mlog_errno(status);
-               make_bad_inode(inode);
                goto bail;
        }
 
+       status = -EINVAL;
        fe = (struct ocfs2_dinode *) bh->b_data;
        if (!OCFS2_IS_VALID_DINODE(fe)) {
-               mlog(ML_ERROR, "Invalid dinode #%"MLFu64": signature = %.*s\n",
-                    fe->i_blkno, 7, fe->i_signature);
-               make_bad_inode(inode);
+               mlog(ML_ERROR, "Invalid dinode #%llu: signature = %.*s\n",
+                    (unsigned long long)fe->i_blkno, 7, fe->i_signature);
                goto bail;
        }
 
-       if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL))
-               sysfile = 1;
+       /*
+        * This is a code bug. Right now the caller needs to
+        * understand whether it is asking for a system file inode or
+        * not so the proper lock names can be built.
+        */
+       mlog_bug_on_msg(!!(fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) !=
+                       !!(args->fi_flags & OCFS2_FI_FLAG_SYSFILE),
+                       "Inode %llu: system file state is ambigous\n",
+                       (unsigned long long)args->fi_blkno);
 
        if (S_ISCHR(le16_to_cpu(fe->i_mode)) ||
            S_ISBLK(le16_to_cpu(fe->i_mode)))
                inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
 
-       status = -EINVAL;
-       if (ocfs2_populate_inode(inode, fe, 0) < 0) {
-               mlog(ML_ERROR, "populate inode failed! i_blkno=%"MLFu64", "
-                    "i_ino=%lu\n", fe->i_blkno, inode->i_ino);
-               make_bad_inode(inode);
+       if (ocfs2_populate_inode(inode, fe, 0) < 0)
                goto bail;
-       }
 
        BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno));
 
-       if (sysfile)
-              OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE;
-
        status = 0;
 
 bail:
+       if (can_lock)
+               ocfs2_meta_unlock(inode, 0);
+
+       if (status < 0)
+               make_bad_inode(inode);
+
        if (args && bh)
                brelse(bh);
 
@@ -417,7 +540,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
                                     struct buffer_head *fe_bh)
 {
        int status = 0;
-       struct ocfs2_journal_handle *handle = NULL;
+       handle_t *handle = NULL;
        struct ocfs2_truncate_context *tc = NULL;
        struct ocfs2_dinode *fe;
 
@@ -429,7 +552,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
        if (!fe->i_clusters)
                goto bail;
 
-       handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS);
+       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
        if (IS_ERR(handle)) {
                status = PTR_ERR(handle);
                handle = NULL;
@@ -443,7 +566,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
                goto bail;
        }
 
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
        handle = NULL;
 
        status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc);
@@ -459,7 +582,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
        }
 bail:
        if (handle)
-               ocfs2_commit_trans(handle);
+               ocfs2_commit_trans(osb, handle);
 
        mlog_exit(status);
        return status;
@@ -473,7 +596,7 @@ static int ocfs2_remove_inode(struct inode *inode,
        int status;
        struct inode *inode_alloc_inode = NULL;
        struct buffer_head *inode_alloc_bh = NULL;
-       struct ocfs2_journal_handle *handle;
+       handle_t *handle;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
 
@@ -487,7 +610,7 @@ static int ocfs2_remove_inode(struct inode *inode,
        }
 
        mutex_lock(&inode_alloc_inode->i_mutex);
-       status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1);
+       status = ocfs2_meta_lock(inode_alloc_inode, &inode_alloc_bh, 1);
        if (status < 0) {
                mutex_unlock(&inode_alloc_inode->i_mutex);
 
@@ -495,7 +618,7 @@ static int ocfs2_remove_inode(struct inode *inode,
                goto bail;
        }
 
-       handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS);
+       handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS);
        if (IS_ERR(handle)) {
                status = PTR_ERR(handle);
                mlog_errno(status);
@@ -534,7 +657,7 @@ static int ocfs2_remove_inode(struct inode *inode,
                mlog_errno(status);
 
 bail_commit:
-       ocfs2_commit_trans(handle);
+       ocfs2_commit_trans(osb, handle);
 bail_unlock:
        ocfs2_meta_unlock(inode_alloc_inode, 1);
        mutex_unlock(&inode_alloc_inode->i_mutex);
@@ -610,7 +733,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
         * delete_inode operation. We do this now to avoid races with
         * recovery completion on other nodes. */
        mutex_lock(&orphan_dir_inode->i_mutex);
-       status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1);
+       status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1);
        if (status < 0) {
                mutex_unlock(&orphan_dir_inode->i_mutex);
 
@@ -675,8 +798,8 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode)
         * never get here as system file inodes should always have a
         * positive link count. */
        if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
-               mlog(ML_ERROR, "Skipping delete of system file %"MLFu64".\n",
-                    oi->ip_blkno);
+               mlog(ML_ERROR, "Skipping delete of system file %llu\n",
+                    (unsigned long long)oi->ip_blkno);
                goto bail_unlock;
        }
 
@@ -715,16 +838,16 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
         * ocfs2_delete_inode, another node might have asked to delete
         * the inode. Recheck our flags to catch this. */
        if (!ocfs2_inode_is_valid_to_delete(inode)) {
-               mlog(0, "Skipping delete of %"MLFu64" because flags changed\n",
-                    oi->ip_blkno);
+               mlog(0, "Skipping delete of %llu because flags changed\n",
+                    (unsigned long long)oi->ip_blkno);
                goto bail;
        }
 
        /* Now that we have an up to date inode, we can double check
         * the link count. */
        if (inode->i_nlink) {
-               mlog(0, "Skipping delete of %"MLFu64" because nlink = %u\n",
-                    oi->ip_blkno, inode->i_nlink);
+               mlog(0, "Skipping delete of %llu because nlink = %u\n",
+                    (unsigned long long)oi->ip_blkno, inode->i_nlink);
                goto bail;
        }
 
@@ -734,9 +857,11 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
                /* for lack of a better error? */
                status = -EEXIST;
                mlog(ML_ERROR,
-                    "Inode %"MLFu64" (on-disk %"MLFu64") not orphaned! "
+                    "Inode %llu (on-disk %llu) not orphaned! "
                     "Disk flags  0x%x, inode flags 0x%x\n",
-                    oi->ip_blkno, di->i_blkno, di->i_flags, oi->ip_flags);
+                    (unsigned long long)oi->ip_blkno,
+                    (unsigned long long)di->i_blkno, di->i_flags,
+                    oi->ip_flags);
                goto bail;
        }
 
@@ -753,8 +878,8 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
         * disk and let them worry about deleting it. */
        if (status == -EBUSY) {
                status = 0;
-               mlog(0, "Skipping delete of %"MLFu64" because it is in use on"
-                    "other nodes\n", oi->ip_blkno);
+               mlog(0, "Skipping delete of %llu because it is in use on"
+                    "other nodes\n", (unsigned long long)oi->ip_blkno);
                goto bail;
        }
        if (status < 0) {
@@ -768,13 +893,13 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
                 * into. This may happen during node death and
                 * recovery knows how to clean it up so we can safely
                 * ignore this inode for now on. */
-               mlog(0, "Nobody knew where inode %"MLFu64" was orphaned!\n",
-                    oi->ip_blkno);
+               mlog(0, "Nobody knew where inode %llu was orphaned!\n",
+                    (unsigned long long)oi->ip_blkno);
        } else {
                *wipe = 1;
 
-               mlog(0, "Inode %"MLFu64" is ok to wipe from orphan dir %d\n",
-                    oi->ip_blkno, oi->ip_orphaned_slot);
+               mlog(0, "Inode %llu is ok to wipe from orphan dir %d\n",
+                    (unsigned long long)oi->ip_blkno, oi->ip_orphaned_slot);
        }
        spin_unlock(&oi->ip_lock);
 
@@ -788,8 +913,8 @@ bail:
 static void ocfs2_cleanup_delete_inode(struct inode *inode,
                                       int sync_data)
 {
-       mlog(0, "Cleanup inode %"MLFu64", sync = %d\n",
-            OCFS2_I(inode)->ip_blkno, sync_data);
+       mlog(0, "Cleanup inode %llu, sync = %d\n",
+            (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data);
        if (sync_data)
                write_inode_now(inode, 1);
        truncate_inode_pages(&inode->i_data, 0);
@@ -836,7 +961,7 @@ void ocfs2_delete_inode(struct inode *inode)
         * allocation lock here as it won't be needed - nobody will
         * have the file open.
         */
-       status = ocfs2_meta_lock(inode, NULL, &di_bh, 1);
+       status = ocfs2_meta_lock(inode, &di_bh, 1);
        if (status < 0) {
                if (status != -ENOENT)
                        mlog_errno(status);
@@ -870,9 +995,15 @@ void ocfs2_delete_inode(struct inode *inode)
                goto bail_unlock_inode;
        }
 
-       /* Mark the inode as successfully deleted. This is important
-        * for ocfs2_clear_inode as it will check this flag and skip
-        * any checkpointing work */
+       /*
+        * Mark the inode as successfully deleted.
+        *
+        * This is important for ocfs2_clear_inode() as it will check
+        * this flag and skip any checkpointing work
+        *
+        * ocfs2_stuff_meta_lvb() also uses this flag to invalidate
+        * the LVB for other nodes.
+        */
        OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED;
 
 bail_unlock_inode:
@@ -897,8 +1028,8 @@ void ocfs2_clear_inode(struct inode *inode)
        if (!inode)
                goto bail;
 
-       mlog(0, "Clearing inode: %"MLFu64", nlink = %u\n",
-            OCFS2_I(inode)->ip_blkno, inode->i_nlink);
+       mlog(0, "Clearing inode: %llu, nlink = %u\n",
+            (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink);
 
        mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL,
                        "Inode=%lu\n", inode->i_ino);
@@ -919,8 +1050,8 @@ void ocfs2_clear_inode(struct inode *inode)
                ocfs2_checkpoint_inode(inode);
 
        mlog_bug_on_msg(!list_empty(&oi->ip_io_markers),
-                       "Clear inode of %"MLFu64", inode has io markers\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu, inode has io markers\n",
+                       (unsigned long long)oi->ip_blkno);
 
        ocfs2_extent_map_drop(inode, 0);
        ocfs2_extent_map_init(inode);
@@ -936,20 +1067,20 @@ void ocfs2_clear_inode(struct inode *inode)
        ocfs2_metadata_cache_purge(inode);
 
        mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached,
-                       "Clear inode of %"MLFu64", inode has %u cache items\n",
-                       oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached);
+                       "Clear inode of %llu, inode has %u cache items\n",
+                       (unsigned long long)oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached);
 
        mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE),
-                       "Clear inode of %"MLFu64", inode has a bad flag\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu, inode has a bad flag\n",
+                       (unsigned long long)oi->ip_blkno);
 
        mlog_bug_on_msg(spin_is_locked(&oi->ip_lock),
-                       "Clear inode of %"MLFu64", inode is locked\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu, inode is locked\n",
+                       (unsigned long long)oi->ip_blkno);
 
        mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex),
-                       "Clear inode of %"MLFu64", io_mutex is locked\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu, io_mutex is locked\n",
+                       (unsigned long long)oi->ip_blkno);
        mutex_unlock(&oi->ip_io_mutex);
 
        /*
@@ -957,19 +1088,13 @@ void ocfs2_clear_inode(struct inode *inode)
         * kernel 1, world 0
         */
        mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem),
-                       "Clear inode of %"MLFu64", alloc_sem is locked\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu, alloc_sem is locked\n",
+                       (unsigned long long)oi->ip_blkno);
        up_write(&oi->ip_alloc_sem);
 
        mlog_bug_on_msg(oi->ip_open_count,
-                       "Clear inode of %"MLFu64" has open count %d\n",
-                       oi->ip_blkno, oi->ip_open_count);
-       mlog_bug_on_msg(!list_empty(&oi->ip_handle_list),
-                       "Clear inode of %"MLFu64" has non empty handle list\n",
-                       oi->ip_blkno);
-       mlog_bug_on_msg(oi->ip_handle,
-                       "Clear inode of %"MLFu64" has non empty handle pointer\n",
-                       oi->ip_blkno);
+                       "Clear inode of %llu has open count %d\n",
+                       (unsigned long long)oi->ip_blkno, oi->ip_open_count);
 
        /* Clear all other flags. */
        oi->ip_flags = OCFS2_INODE_CACHE_INLINE;
@@ -991,18 +1116,16 @@ void ocfs2_drop_inode(struct inode *inode)
 
        mlog_entry_void();
 
-       mlog(0, "Drop inode %"MLFu64", nlink = %u, ip_flags = 0x%x\n",
-            oi->ip_blkno, inode->i_nlink, oi->ip_flags);
+       mlog(0, "Drop inode %llu, nlink = %u, ip_flags = 0x%x\n",
+            (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags);
 
        /* Testing ip_orphaned_slot here wouldn't work because we may
         * not have gotten a delete_inode vote from any other nodes
         * yet. */
-       if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) {
-               mlog(0, "Inode was orphaned on another node, clearing nlink.\n");
-               inode->i_nlink = 0;
-       }
-
-       generic_drop_inode(inode);
+       if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED)
+               generic_delete_inode(inode);
+       else
+               generic_drop_inode(inode);
 
        mlog_exit_void();
 }
@@ -1022,12 +1145,8 @@ struct buffer_head *ocfs2_bread(struct inode *inode,
        u64 p_blkno;
        int readflags = OCFS2_BH_CACHED;
 
-#if 0
-       /* only turn this on if we know we can deal with read_block
-        * returning nothing */
        if (reada)
                readflags |= OCFS2_BH_READAHEAD;
-#endif
 
        if (((u64)block << inode->i_sb->s_blocksize_bits) >=
            i_size_read(inode)) {
@@ -1069,8 +1188,8 @@ int ocfs2_inode_revalidate(struct dentry *dentry)
        struct inode *inode = dentry->d_inode;
        int status = 0;
 
-       mlog_entry("(inode = 0x%p, ino = %"MLFu64")\n", inode,
-                  inode ? OCFS2_I(inode)->ip_blkno : 0ULL);
+       mlog_entry("(inode = 0x%p, ino = %llu)\n", inode,
+                  inode ? (unsigned long long)OCFS2_I(inode)->ip_blkno : 0ULL);
 
        if (!inode) {
                mlog(0, "eep, no inode!\n");
@@ -1089,7 +1208,7 @@ int ocfs2_inode_revalidate(struct dentry *dentry)
 
        /* Let ocfs2_meta_lock do the work of updating our struct
         * inode for us. */
-       status = ocfs2_meta_lock(inode, NULL, NULL, 0);
+       status = ocfs2_meta_lock(inode, NULL, 0);
        if (status < 0) {
                if (status != -ENOENT)
                        mlog_errno(status);
@@ -1107,14 +1226,15 @@ bail:
  * struct inode.
  * Only takes ip_lock.
  */
-int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle,
+int ocfs2_mark_inode_dirty(handle_t *handle,
                           struct inode *inode,
                           struct buffer_head *bh)
 {
        int status;
        struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
 
-       mlog_entry("(inode %"MLFu64")\n", OCFS2_I(inode)->ip_blkno);
+       mlog_entry("(inode %llu)\n",
+                  (unsigned long long)OCFS2_I(inode)->ip_blkno);
 
        status = ocfs2_journal_access(handle, inode, bh,
                                      OCFS2_JOURNAL_ACCESS_WRITE);
@@ -1125,12 +1245,16 @@ int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle,
 
        spin_lock(&OCFS2_I(inode)->ip_lock);
        fe->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters);
+       fe->i_attr = cpu_to_le32(OCFS2_I(inode)->ip_attr);
        spin_unlock(&OCFS2_I(inode)->ip_lock);
 
        fe->i_size = cpu_to_le64(i_size_read(inode));
        fe->i_links_count = cpu_to_le16(inode->i_nlink);
-       fe->i_uid = cpu_to_le32(inode->i_uid);
-       fe->i_gid = cpu_to_le32(inode->i_gid);
+       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode),
+               inode->i_uid, inode->i_tag));
+       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode),
+               inode->i_gid, inode->i_tag));
+       /* i_tag = = cpu_to_le16(inode->i_tag); */
        fe->i_mode = cpu_to_le16(inode->i_mode);
        fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
        fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
@@ -1158,17 +1282,25 @@ leave:
 void ocfs2_refresh_inode(struct inode *inode,
                         struct ocfs2_dinode *fe)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       uid_t uid;
+       gid_t gid;
 
        spin_lock(&OCFS2_I(inode)->ip_lock);
 
        OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
+       OCFS2_I(inode)->ip_attr = le32_to_cpu(fe->i_attr);
+       /* OCFS2_I(inode)->ip_flags &= ~OCFS2_FL_MASK;
+          OCFS2_I(inode)->ip_flags |= le32_to_cpu(fe->i_flags) & OCFS2_FL_MASK; */
+       ocfs2_set_inode_flags(inode);
        i_size_write(inode, le64_to_cpu(fe->i_size));
        inode->i_nlink = le16_to_cpu(fe->i_links_count);
-       inode->i_uid = le32_to_cpu(fe->i_uid);
-       inode->i_gid = le32_to_cpu(fe->i_gid);
+       uid = le32_to_cpu(fe->i_uid);
+       gid = le32_to_cpu(fe->i_gid);
+       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,
+               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
        inode->i_mode = le16_to_cpu(fe->i_mode);
-       inode->i_blksize = (u32) osb->s_clustersize;
        if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
                inode->i_blocks = 0;
        else