Whamcloud - gitweb
LU-932 llite: cleanup ll_inode_info to reduce inode size
authorFan Yong <yong.fan@whamcloud.com>
Fri, 16 Dec 2011 05:58:37 +0000 (13:58 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 4 Jan 2012 16:26:51 +0000 (11:26 -0500)
ll_inode_info contains many special-used members, some of them are only
used for directory object, some are only used for non-directory object.
Share memory between those non-coexist members to reduce inode size.

Signed-off-by: Fan Yong <yong.fan@whamcloud.com>
Change-Id: Ic10014b2121f64718667addb77ed009aa29c1b4c
Reviewed-on: http://review.whamcloud.com/1691
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
12 files changed:
lustre/include/lclient.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/llite_lib.h
lustre/liblustre/super.c
lustre/llite/file.c
lustre/llite/llite_close.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/llite/remote_perm.c
lustre/llite/super25.c
lustre/llite/xattr.c

index adc4b5a..6a5425c 100644 (file)
@@ -358,7 +358,7 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr,
 
 struct cl_page *ccc_vmpage_page_transient(cfs_page_t *vmpage);
 int ccc_object_invariant(const struct cl_object *obj);
-int cl_inode_init(struct inode *inode, struct lustre_md *md);
+int cl_file_inode_init(struct inode *inode, struct lustre_md *md);
 void cl_inode_fini(struct inode *inode);
 int cl_local_size(struct inode *inode);
 
index c0798ad..821ef6e 100644 (file)
@@ -1158,13 +1158,15 @@ struct cl_page *ccc_vmpage_page_transient(cfs_page_t *vmpage)
 }
 
 /**
- * Initializes or updates CLIO part when new meta-data arrives from the
- * server.
+ * Initialize or update CLIO structures for regular files when new
+ * meta-data arrives from the server.
  *
- *     - allocates cl_object if necessary,
- *     - updated layout, if object was already here.
+ * \param inode regular file inode
+ * \param md    new file metadata from MDS
+ * - allocates cl_object if necessary,
+ * - updated layout, if object was already here.
  */
-int cl_inode_init(struct inode *inode, struct lustre_md *md)
+int cl_file_inode_init(struct inode *inode, struct lustre_md *md)
 {
         struct lu_env        *env;
         struct cl_inode_info *lli;
@@ -1181,9 +1183,7 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md)
         int refcheck;
 
         LASSERT(md->body->valid & OBD_MD_FLID);
-
-        if (!S_ISREG(cl_inode_mode(inode)))
-                return 0;
+        LASSERT(S_ISREG(cl_inode_mode(inode)));
 
         env = cl_env_get(&refcheck);
         if (IS_ERR(env))
index ea15572..b418240 100644 (file)
@@ -370,8 +370,6 @@ void put_io_group(struct llu_io_group *group);
 
 int cl_sb_init(struct llu_sb_info *sbi);
 int cl_sb_fini(struct llu_sb_info *sbi);
-int cl_inode_init(struct inode *inode, struct lustre_md *md);
-void cl_inode_fini(struct inode *inode);
 
 void llu_io_init(struct cl_io *io, struct inode *inode, int write);
 
index 5bf3558..863b93c 100644 (file)
@@ -151,7 +151,7 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
 
         if (lsm != NULL) {
                 if (lli->lli_smd == NULL) {
-                        cl_inode_init(inode, md);
+                        cl_file_inode_init(inode, md);
                         lli->lli_smd = lsm;
                         lli->lli_maxbytes = lsm->lsm_maxbytes;
                         if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
index 78eb805..50763ed 100644 (file)
@@ -318,7 +318,8 @@ int ll_file_release(struct inode *inode, struct file *file)
         /* The last ref on @file, maybe not the the owner pid of statahead.
          * Different processes can open the same dir, "ll_opendir_key" means:
          * it is me that should stop the statahead thread. */
-        if (lli->lli_opendir_key == fd && lli->lli_opendir_pid != 0)
+        if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd &&
+            lli->lli_opendir_pid != 0)
                 ll_stop_statahead(inode, lli->lli_opendir_key);
 
         if (inode->i_sb->s_root == file->f_dentry) {
@@ -327,9 +328,11 @@ int ll_file_release(struct inode *inode, struct file *file)
                 RETURN(0);
         }
 
-        if (lsm)
-                lov_test_and_clear_async_rc(lsm);
-        lli->lli_async_rc = 0;
+        if (!S_ISDIR(inode->i_mode)) {
+                if (lsm)
+                        lov_test_and_clear_async_rc(lsm);
+                lli->lli_async_rc = 0;
+        }
 
         rc = ll_md_close(sbi->ll_md_exp, inode, file);
 
@@ -519,8 +522,8 @@ int ll_file_open(struct inode *inode, struct file *file)
         fd->fd_file = file;
         if (S_ISDIR(inode->i_mode)) {
                 cfs_spin_lock(&lli->lli_sa_lock);
-                if (lli->lli_opendir_key == NULL && lli->lli_opendir_pid == 0 &&
-                    lli->lli_sai == NULL) {
+                if (lli->lli_opendir_key == NULL && lli->lli_sai == NULL &&
+                    lli->lli_opendir_pid == 0) {
                         lli->lli_opendir_key = fd;
                         lli->lli_opendir_pid = cfs_curproc_pid();
                         opendir_set = 1;
@@ -1916,6 +1919,8 @@ int ll_flush(struct file *file)
         struct lov_stripe_md *lsm = lli->lli_smd;
         int rc, err;
 
+        LASSERT(!S_ISDIR(inode->i_mode));
+
         /* the application should know write failure already. */
         if (lli->lli_write_rc)
                 return 0;
@@ -1952,14 +1957,16 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
 
         /* catch async errors that were recorded back when async writeback
          * failed for pages in this mapping. */
-        err = lli->lli_async_rc;
-        lli->lli_async_rc = 0;
-        if (rc == 0)
-                rc = err;
-        if (lsm) {
-                err = lov_test_and_clear_async_rc(lsm);
+        if (!S_ISDIR(inode->i_mode)) {
+                err = lli->lli_async_rc;
+                lli->lli_async_rc = 0;
                 if (rc == 0)
                         rc = err;
+                if (lsm) {
+                        err = lov_test_and_clear_async_rc(lsm);
+                        if (rc == 0)
+                                rc = err;
+                }
         }
 
         oc = ll_mdscapa_get(inode);
@@ -1998,7 +2005,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                         rc = err;
                 OBDO_FREE(oinfo->oi_oa);
                 OBD_FREE_PTR(oinfo);
-                lli->lli_write_rc = err < 0 ? : 0;
+                lli->lli_write_rc = rc < 0 ? rc : 0;
         }
 
         RETURN(rc);
index b96081e..3b2b90b 100644 (file)
@@ -95,10 +95,10 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags)
                 struct ll_close_queue *lcq = ll_i2sbi(inode)->ll_lcq;
 
                 if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                         CWARN("ino %lu/%u(flags %lu) som valid it just after "
-                               "recovery\n",
-                               inode->i_ino, inode->i_generation,
-                               lli->lli_flags);
+                        CWARN("ino %lu/%u(flags %u) som valid it just after "
+                              "recovery\n",
+                              inode->i_ino, inode->i_generation,
+                              lli->lli_flags);
                 /* DONE_WRITING is allowed and inode has no dirty page. */
                 cfs_spin_lock(&lcq->lcq_lock);
 
@@ -131,7 +131,7 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data)
         op_data->op_flags |= MF_SOM_CHANGE;
         /* Check if Size-on-MDS attributes are valid. */
         if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                CERROR("ino %lu/%u(flags %lu) som valid it just after "
+                CERROR("ino %lu/%u(flags %u) som valid it just after "
                        "recovery\n", inode->i_ino, inode->i_generation,
                        lli->lli_flags);
 
@@ -229,7 +229,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
 
         LASSERT(op_data != NULL);
         if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                CERROR("ino %lu/%u(flags %lu) som valid it just after "
+                CERROR("ino %lu/%u(flags %u) som valid it just after "
                        "recovery\n", inode->i_ino, inode->i_generation,
                        lli->lli_flags);
 
index 5d95c4e..4803907 100644 (file)
@@ -120,96 +120,135 @@ enum lli_flags {
          * be sent to MDS. */
         LLIF_SOM_DIRTY          = (1 << 3),
         /* File is contented */
-        LLIF_CONTENDED         = (1 << 4),
+        LLIF_CONTENDED          = (1 << 4),
         /* Truncate uses server lock for this file */
-        LLIF_SRVLOCK           = (1 << 5)
+        LLIF_SRVLOCK            = (1 << 5),
 
 };
 
 struct ll_inode_info {
-        int                     lli_inode_magic;
-        cfs_semaphore_t         lli_size_sem;           /* protect open and change size */
-        void                   *lli_size_sem_owner;
-        cfs_semaphore_t         lli_write_sem;
-        cfs_rw_semaphore_t      lli_trunc_sem;
-        char                   *lli_symlink_name;
-        __u64                   lli_maxbytes;
-        __u64                   lli_ioepoch;
-        unsigned long           lli_flags;
-
-        /* this lock protects posix_acl, pending_write_llaps, mmap_cnt */
-        cfs_spinlock_t          lli_lock;
-        cfs_list_t              lli_close_list;
-        /* handle is to be sent to MDS later on done_writing and setattr.
-         * Open handle data are needed for the recovery to reconstruct
-         * the inode state on the MDS. XXX: recovery is not ready yet. */
-        struct obd_client_handle *lli_pending_och;
-
-        /* for writepage() only to communicate to fsync */
-        int                     lli_async_rc;
-        int                     lli_write_rc;
+        __u32                           lli_inode_magic;
+        __u32                           lli_flags;
+        __u64                           lli_ioepoch;
 
-        struct posix_acl       *lli_posix_acl;
-
-        /* remote permission hash */
-        cfs_hlist_head_t       *lli_remote_perms;
-        unsigned long           lli_rmtperm_utime;
-        cfs_semaphore_t         lli_rmtperm_sem;
-
-        cfs_list_t              lli_dead_list;
-
-        cfs_semaphore_t         lli_och_sem; /* Protects access to och pointers
-                                                and their usage counters, also
-                                                atomicity of check-update of
-                                                lli_smd */
-        /* We need all three because every inode may be opened in different
-           modes */
-        struct obd_client_handle *lli_mds_read_och;
-        __u64                   lli_open_fd_read_count;
-        struct obd_client_handle *lli_mds_write_och;
-        __u64                   lli_open_fd_write_count;
-        struct obd_client_handle *lli_mds_exec_och;
-        __u64                   lli_open_fd_exec_count;
+        cfs_spinlock_t                  lli_lock;
+        struct posix_acl               *lli_posix_acl;
 
-        struct inode            lli_vfs_inode;
+        cfs_hlist_head_t               *lli_remote_perms;
+        cfs_semaphore_t                 lli_rmtperm_sem;
 
         /* identifying fields for both metadata and data stacks. */
-        struct lu_fid           lli_fid;
+        struct lu_fid                   lli_fid;
         /* Parent fid for accessing default stripe data on parent directory
          * for allocating OST objects after a mknod() and later open-by-FID. */
-        struct lu_fid           lli_pfid;
-        struct lov_stripe_md   *lli_smd;
+        struct lu_fid                   lli_pfid;
 
-        /* fid capability */
+        cfs_list_t                      lli_close_list;
+        cfs_list_t                      lli_oss_capas;
         /* open count currently used by capability only, indicate whether
          * capability needs renewal */
-        cfs_atomic_t            lli_open_count;
-        struct obd_capa        *lli_mds_capa;
-        cfs_list_t              lli_oss_capas;
-
-        /* metadata statahead */
-        /* protect statahead stuff: lli_opendir_pid, lli_opendir_key, lli_sai,
-         * and so on. */
-        cfs_spinlock_t          lli_sa_lock;
-        /*
-         * "opendir_pid" is the token when lookup/revalid -- I am the owner of
-         * dir statahead.
-         */
-        pid_t                   lli_opendir_pid;
-        /*
-         * since parent-child threads can share the same @file struct,
-         * "opendir_key" is the token when dir close for case of parent exit
-         * before child -- it is me should cleanup the dir readahead. */
-        void                   *lli_opendir_key;
-        struct ll_statahead_info *lli_sai;
-        __u64                   lli_sa_pos;
-        struct cl_object       *lli_clob;
+        cfs_atomic_t                    lli_open_count;
+        struct obd_capa                *lli_mds_capa;
+        cfs_time_t                      lli_rmtperm_time;
+
+        /* handle is to be sent to MDS later on done_writing and setattr.
+         * Open handle data are needed for the recovery to reconstruct
+         * the inode state on the MDS. XXX: recovery is not ready yet. */
+        struct obd_client_handle       *lli_pending_och;
+
+        /* We need all three because every inode may be opened in different
+         * modes */
+        struct obd_client_handle       *lli_mds_read_och;
+        struct obd_client_handle       *lli_mds_write_och;
+        struct obd_client_handle       *lli_mds_exec_och;
+        __u64                           lli_open_fd_read_count;
+        __u64                           lli_open_fd_write_count;
+        __u64                           lli_open_fd_exec_count;
+        /* Protects access to och pointers and their usage counters, also
+         * atomicity of check-update of lli_smd */
+        cfs_semaphore_t                 lli_och_sem;
+
+        struct inode                    lli_vfs_inode;
+
         /* the most recent timestamps obtained from mds */
-        struct ost_lvb          lli_lvb;
-        /**
-         * serialize normal readdir and statahead-readdir
+        struct ost_lvb                  lli_lvb;
+
+        /* Try to make the d::member and f::member are aligned. Before using
+         * these members, make clear whether it is directory or not. */
+        union {
+                /* for directory */
+                struct {
+                        /* serialize normal readdir and statahead-readdir. */
+                        cfs_semaphore_t                 d_readdir_sem;
+
+                        /* metadata statahead */
+                        /* since parent-child threads can share the same @file
+                         * struct, "opendir_key" is the token when dir close for
+                         * case of parent exit before child -- it is me should
+                         * cleanup the dir readahead. */
+                        void                           *d_opendir_key;
+                        struct ll_statahead_info       *d_sai;
+                        __u64                           d_sa_pos;
+                        struct posix_acl               *d_def_acl;
+                        /* protect statahead stuff. */
+                        cfs_spinlock_t                  d_sa_lock;
+                        /* "opendir_pid" is the token when lookup/revalid
+                         * -- I am the owner of dir statahead. */
+                        pid_t                           d_opendir_pid;
+                } d;
+
+#define lli_readdir_sem         u.d.d_readdir_sem
+#define lli_opendir_key         u.d.d_opendir_key
+#define lli_sai                 u.d.d_sai
+#define lli_sa_pos              u.d.d_sa_pos
+#define lli_def_acl             u.d.d_def_acl
+#define lli_sa_lock             u.d.d_sa_lock
+#define lli_opendir_pid         u.d.d_opendir_pid
+
+                /* for non-directory */
+                struct {
+                        cfs_semaphore_t                 f_size_sem;
+                        void                           *f_size_sem_owner;
+                        char                           *f_symlink_name;
+                        __u64                           f_maxbytes;
+                        /*
+                         * cfs_rw_semaphore_t {
+                         *    signed long      count;     // align u.d.d_def_acl
+                         *    cfs_spinlock_t   wait_lock; // align u.d.d_sa_lock
+                         *    struct list_head wait_list;
+                         * }
+                         */
+                        cfs_rw_semaphore_t              f_trunc_sem;
+                        cfs_semaphore_t                 f_write_sem;
+
+                        /* for writepage() only to communicate to fsync */
+                        int                             f_async_rc;
+                        int                             f_write_rc;
+                } f;
+
+#define lli_size_sem            u.f.f_size_sem
+#define lli_size_sem_owner      u.f.f_size_sem_owner
+#define lli_symlink_name        u.f.f_symlink_name
+#define lli_maxbytes            u.f.f_maxbytes
+#define lli_trunc_sem           u.f.f_trunc_sem
+#define lli_write_sem           u.f.f_write_sem
+#define lli_async_rc            u.f.f_async_rc
+#define lli_write_rc            u.f.f_write_rc
+
+        } u;
+
+        /* XXX: For following frequent used members, although they maybe special
+         *      used for non-directory object, it is some time-wasting to check
+         *      whether the object is directory or not before using them. On the
+         *      other hand, currently, sizeof(f) > sizeof(d), it cannot reduce
+         *      the "ll_inode_info" size even if moving those members into u.f.
+         *      So keep them out side.
+         *
+         *      In the future, if more members are added only for directory,
+         *      some of the following members can be moved into u.f.
          */
-        cfs_semaphore_t         lli_readdir_sem;
+        struct lov_stripe_md           *lli_smd;
+        struct cl_object               *lli_clob;
 };
 
 /*
@@ -1088,12 +1127,8 @@ extern struct lu_device_type vvp_device_type;
 /**
  * Common IO arguments for various VFS I/O interfaces.
  */
-
 int cl_sb_init(struct super_block *sb);
 int cl_sb_fini(struct super_block *sb);
-int cl_inode_init(struct inode *inode, struct lustre_md *md);
-void cl_inode_fini(struct inode *inode);
-
 enum cl_lock_mode  vvp_mode_from_vma(struct vm_area_struct *vma);
 void ll_io_init(struct cl_io *io, const struct file *file, int write);
 
index 6bcc212..70d0fcb 100644 (file)
@@ -854,28 +854,49 @@ next:
 void ll_lli_init(struct ll_inode_info *lli)
 {
         lli->lli_inode_magic = LLI_INODE_MAGIC;
-        cfs_sema_init(&lli->lli_size_sem, 1);
-        cfs_sema_init(&lli->lli_write_sem, 1);
-        cfs_init_rwsem(&lli->lli_trunc_sem);
         lli->lli_flags = 0;
-        lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
+        lli->lli_ioepoch = 0;
         cfs_spin_lock_init(&lli->lli_lock);
-        CFS_INIT_LIST_HEAD(&lli->lli_close_list);
-        lli->lli_inode_magic = LLI_INODE_MAGIC;
-        cfs_sema_init(&lli->lli_och_sem, 1);
-        lli->lli_mds_read_och = lli->lli_mds_write_och = NULL;
-        lli->lli_mds_exec_och = NULL;
-        lli->lli_open_fd_read_count = lli->lli_open_fd_write_count = 0;
-        lli->lli_open_fd_exec_count = 0;
-        CFS_INIT_LIST_HEAD(&lli->lli_dead_list);
+        lli->lli_posix_acl = NULL;
         lli->lli_remote_perms = NULL;
-        lli->lli_rmtperm_utime = 0;
         cfs_sema_init(&lli->lli_rmtperm_sem, 1);
+        /* Do not set lli_fid, it has been initialized already. */
+        fid_zero(&lli->lli_pfid);
+        CFS_INIT_LIST_HEAD(&lli->lli_close_list);
         CFS_INIT_LIST_HEAD(&lli->lli_oss_capas);
-        cfs_spin_lock_init(&lli->lli_sa_lock);
+        cfs_atomic_set(&lli->lli_open_count, 0);
+        lli->lli_mds_capa = NULL;
+        lli->lli_rmtperm_time = 0;
+        lli->lli_pending_och = NULL;
+        lli->lli_mds_read_och = NULL;
+        lli->lli_mds_write_och = NULL;
+        lli->lli_mds_exec_och = NULL;
+        lli->lli_open_fd_read_count = 0;
+        lli->lli_open_fd_write_count = 0;
+        lli->lli_open_fd_exec_count = 0;
+        cfs_sema_init(&lli->lli_och_sem, 1);
+        lli->lli_smd = NULL;
         lli->lli_clob = NULL;
-        cfs_sema_init(&lli->lli_readdir_sem, 1);
-        fid_zero(&lli->lli_pfid);
+
+        LASSERT(lli->lli_vfs_inode.i_mode != 0);
+        if (S_ISDIR(lli->lli_vfs_inode.i_mode)) {
+                cfs_sema_init(&lli->lli_readdir_sem, 1);
+                lli->lli_opendir_key = NULL;
+                lli->lli_sai = NULL;
+                lli->lli_sa_pos = 0;
+                lli->lli_def_acl = NULL;
+                cfs_spin_lock_init(&lli->lli_sa_lock);
+                lli->lli_opendir_pid = 0;
+        } else {
+                cfs_sema_init(&lli->lli_size_sem, 1);
+                lli->lli_size_sem_owner = NULL;
+                lli->lli_symlink_name = NULL;
+                lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
+                cfs_init_rwsem(&lli->lli_trunc_sem);
+                cfs_sema_init(&lli->lli_write_sem, 1);
+                lli->lli_async_rc = 0;
+                lli->lli_write_rc = 0;
+        }
 }
 
 static inline int ll_bdi_register(struct backing_dev_info *bdi)
@@ -1103,8 +1124,8 @@ void ll_clear_inode(struct inode *inode)
 
         if (S_ISDIR(inode->i_mode)) {
                 /* these should have been cleared in ll_file_release */
-                LASSERT(lli->lli_sai == NULL);
                 LASSERT(lli->lli_opendir_key == NULL);
+                LASSERT(lli->lli_sai == NULL);
                 LASSERT(lli->lli_opendir_pid == 0);
         }
 
@@ -1123,7 +1144,7 @@ void ll_clear_inode(struct inode *inode)
         if (lli->lli_mds_read_och)
                 ll_md_real_close(inode, FMODE_READ);
 
-        if (lli->lli_symlink_name) {
+        if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
                 OBD_FREE(lli->lli_symlink_name,
                          strlen(lli->lli_symlink_name) + 1);
                 lli->lli_symlink_name = NULL;
@@ -1347,7 +1368,8 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         UNLOCK_INODE_MUTEX(inode);
         if (ia_valid & ATTR_SIZE)
                 UP_WRITE_I_ALLOC_SEM(inode);
-        cfs_down_write(&lli->lli_trunc_sem);
+        if (!S_ISDIR(inode->i_mode))
+                cfs_down_write(&lli->lli_trunc_sem);
         LOCK_INODE_MUTEX(inode);
         if (ia_valid & ATTR_SIZE)
                 DOWN_WRITE_I_ALLOC_SEM(inode);
@@ -1388,7 +1410,8 @@ out:
                         rc1 = ll_setattr_done_writing(inode, op_data, mod);
                 ll_finish_md_op_data(op_data);
         }
-        cfs_up_write(&lli->lli_trunc_sem);
+        if (!S_ISDIR(inode->i_mode))
+                cfs_up_write(&lli->lli_trunc_sem);
         return rc ? rc : rc1;
 }
 
@@ -1519,6 +1542,8 @@ void ll_inode_size_lock(struct inode *inode, int lock_lsm)
         struct ll_inode_info *lli;
         struct lov_stripe_md *lsm;
 
+        LASSERT(!S_ISDIR(inode->i_mode));
+
         lli = ll_i2info(inode);
         LASSERT(lli->lli_size_sem_owner != current);
         cfs_down(&lli->lli_size_sem);
@@ -1556,6 +1581,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 
         LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
         if (lsm != NULL) {
+                LASSERT(S_ISREG(inode->i_mode));
+
                 cfs_down(&lli->lli_och_sem);
                 if (lli->lli_smd == NULL) {
                         if (lsm->lsm_magic != LOV_MAGIC_V1 &&
@@ -1565,11 +1592,11 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                         }
                         CDEBUG(D_INODE, "adding lsm %p to inode %lu/%u(%p)\n",
                                lsm, inode->i_ino, inode->i_generation, inode);
-                        /* cl_inode_init must go before lli_smd or a race is
-                         * possible where client thinks the file has stripes,
+                        /* cl_file_inode_init must go before lli_smd or a race
+                         * is possible where client thinks the file has stripes,
                          * but lov raid0 is not setup yet and parallel e.g.
                          * glimpse would try to use uninitialized lov */
-                        cl_inode_init(inode, md);
+                        cl_file_inode_init(inode, md);
                         cfs_spin_lock(&lli->lli_lock);
                         lli->lli_smd = lsm;
                         cfs_spin_unlock(&lli->lli_lock);
@@ -1685,7 +1712,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                                 if (lli->lli_flags & (LLIF_DONE_WRITING |
                                                       LLIF_EPOCH_PENDING |
                                                       LLIF_SOM_DIRTY)) {
-                                        CERROR("ino %lu flags %lu still has "
+                                        CERROR("ino %lu flags %u still has "
                                                "size authority! do not trust "
                                                "the size got from MDS\n",
                                                inode->i_ino, lli->lli_flags);
@@ -1729,8 +1756,6 @@ void ll_read_inode2(struct inode *inode, void *opaque)
         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
                PFID(&lli->lli_fid), inode);
 
-        ll_lli_init(lli);
-
         LASSERT(!lli->lli_smd);
 
         /* Core attributes from the MDS first.  This is a new inode, and
index e5393a1..52945c4 100644 (file)
@@ -114,6 +114,20 @@ static int ll_set_inode(struct inode *inode, void *opaque)
         }
 
         lli->lli_fid = body->fid1;
+        if (unlikely(!(body->valid & OBD_MD_FLTYPE))) {
+                CERROR("Can not initialize inode "DFID" without object type: "
+                       "valid = "LPX64"\n", PFID(&lli->lli_fid), body->valid);
+                return -EINVAL;
+        }
+
+        inode->i_mode = (inode->i_mode & ~S_IFMT) | (body->mode & S_IFMT);
+        if (unlikely(inode->i_mode == 0)) {
+                CERROR("Invalid inode "DFID" type\n", PFID(&lli->lli_fid));
+                return -EINVAL;
+        }
+
+        ll_lli_init(lli);
+
         return 0;
 }
 
@@ -138,7 +152,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash,
                         ll_read_inode2(inode, md);
                         if (S_ISREG(inode->i_mode) &&
                             ll_i2info(inode)->lli_clob == NULL)
-                                rc = cl_inode_init(inode, md);
+                                rc = cl_file_inode_init(inode, md);
                         if (rc != 0) {
                                 md->lsm = NULL;
                                 make_bad_inode(inode);
@@ -148,7 +162,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash,
                         } else
                                 unlock_new_inode(inode);
                 } else if (!(inode->i_state & (I_FREEING | I_CLEAR)))
-                                ll_update_inode(inode, md);
+                        ll_update_inode(inode, md);
                 CDEBUG(D_VFSTRACE, "got inode: %p for "DFID"\n",
                        inode, PFID(&md->body->fid1));
         }
index f90de1f..28263c0 100644 (file)
@@ -236,7 +236,7 @@ again:
                 lrp->lrp_fsgid       = perm->rp_fsgid;
                 cfs_hlist_add_head(&lrp->lrp_list, head);
         }
-        lli->lli_rmtperm_utime = jiffies;
+        lli->lli_rmtperm_time = cfs_time_current();
         cfs_spin_unlock(&lli->lli_lock);
 
         CDEBUG(D_SEC, "new remote perm@%p: %u/%u/%u/%u - %#x\n",
@@ -253,12 +253,12 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
         struct ptlrpc_request *req = NULL;
         struct mdt_remote_perm *perm;
         struct obd_capa *oc;
-        unsigned long utime;
+        cfs_time_t save;
         int i = 0, rc;
         ENTRY;
 
         do {
-                utime = lli->lli_rmtperm_utime;
+                save = lli->lli_rmtperm_time;
                 rc = do_check_remote_perm(lli, mask);
                 if (!rc || (rc != -ENOENT && i))
                         break;
@@ -267,7 +267,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
 
                 cfs_down(&lli->lli_rmtperm_sem);
                 /* check again */
-                if (utime != lli->lli_rmtperm_utime) {
+                if (save != lli->lli_rmtperm_time) {
                         rc = do_check_remote_perm(lli, mask);
                         if (!rc || (rc != -ENOENT && i)) {
                                 cfs_up(&lli->lli_rmtperm_sem);
index 1e426d4..c8e4131 100644 (file)
@@ -58,8 +58,6 @@ static struct inode *ll_alloc_inode(struct super_block *sb)
                 return NULL;
 
         inode_init_once(&lli->lli_vfs_inode);
-        ll_lli_init(lli);
-
         return &lli->lli_vfs_inode;
 }
 
index 013a1b3..fc4b7da 100644 (file)
@@ -508,10 +508,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
                 GOTO(out, rc);
 
         if (S_ISREG(inode->i_mode)) {
-                struct ll_inode_info *lli = ll_i2info(inode);
-                struct lov_stripe_md *lsm = NULL;
-                lsm = lli->lli_smd;
-                if (lsm == NULL)
+                if (ll_i2info(inode)->lli_smd == NULL)
                         rc2 = -1;
         } else if (S_ISDIR(inode->i_mode)) {
                 rc2 = ll_dir_getstripe(inode, &lmm, &lmmsize, &request);