Whamcloud - gitweb
LU-3254 llite: Update layout_gen only if layout change succeed
[fs/lustre-release.git] / lustre / llite / file.c
index 0abafda..e0019c3 100644 (file)
 
 #include "cl_object.h"
 
-struct ll_file_data *ll_file_data_get(void)
+static int
+ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg);
+
+static int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
+                         bool *lease_broken);
+
+static enum llioc_iter
+ll_iocontrol_call(struct inode *inode, struct file *file,
+                 unsigned int cmd, unsigned long arg, int *rcp);
+
+static struct ll_file_data *ll_file_data_get(void)
 {
        struct ll_file_data *fd;
 
@@ -261,8 +271,8 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode)
        RETURN(rc);
 }
 
-int ll_md_close(struct obd_export *md_exp, struct inode *inode,
-                struct file *file)
+static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
+                      struct file *file)
 {
         struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -500,8 +510,8 @@ static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it,
        return md_set_open_replay_data(md_exp, och, it);
 }
 
-int ll_local_open(struct file *file, struct lookup_intent *it,
-                  struct ll_file_data *fd, struct obd_client_handle *och)
+static int ll_local_open(struct file *file, struct lookup_intent *it,
+                        struct ll_file_data *fd, struct obd_client_handle *och)
 {
         struct inode *inode = file->f_dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -757,8 +767,9 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock,
 /**
  * Acquire a lease and open the file.
  */
-struct obd_client_handle *ll_lease_open(struct inode *inode, struct file *file,
-                                       fmode_t fmode, __u64 open_flags)
+static struct obd_client_handle *
+ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
+             __u64 open_flags)
 {
        struct lookup_intent it = { .it_op = IT_OPEN };
        struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -891,14 +902,13 @@ out:
                OBD_FREE_PTR(och);
        RETURN(ERR_PTR(rc));
 }
-EXPORT_SYMBOL(ll_lease_open);
 
 /**
  * Release lease and close the file.
  * It will check if the lease has ever broken.
  */
-int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
-                       bool *lease_broken)
+static int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
+                         bool *lease_broken)
 {
        struct ldlm_lock *lock;
        bool cancelled = true;
@@ -925,7 +935,6 @@ int ll_lease_close(struct obd_client_handle *och, struct inode *inode,
                                       NULL);
        RETURN(rc);
 }
-EXPORT_SYMBOL(ll_lease_close);
 
 /* Fills the obdo with the attributes for the lsm */
 static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp,
@@ -1100,7 +1109,7 @@ static bool file_is_noatime(const struct file *file)
        return false;
 }
 
-void ll_io_init(struct cl_io *io, const struct file *file, int write)
+static void ll_io_init(struct cl_io *io, const struct file *file, int write)
 {
         struct inode *inode = file->f_dentry->d_inode;
 
@@ -1688,7 +1697,8 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg)
        RETURN(rc);
 }
 
-int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
+static int
+ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg)
 {
         struct ll_inode_info   *lli = ll_i2info(inode);
         struct ll_file_data    *fd = LUSTRE_FPRIVATE(file);
@@ -1811,8 +1821,8 @@ out:
  * Get size for inode for which FIEMAP mapping is requested.
  * Make the FIEMAP get_info call and returns the result.
  */
-int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
-              int num_bytes)
+static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
+                       int num_bytes)
 {
        struct obd_export *exp = ll_i2dtexp(inode);
        struct lov_stripe_md *lsm = NULL;
@@ -2269,8 +2279,8 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
 
        attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
        attr->ia_mode |= S_IFREG;
-       attr->ia_uid = hui->hui_uid;
-       attr->ia_gid = hui->hui_gid;
+       attr->ia_uid = make_kuid(&init_user_ns, hui->hui_uid);
+       attr->ia_gid = make_kgid(&init_user_ns, hui->hui_gid);
        attr->ia_size = hui->hui_size;
        attr->ia_mtime.tv_sec = hui->hui_mtime;
        attr->ia_mtime.tv_nsec = hui->hui_mtime_ns;
@@ -2296,7 +2306,8 @@ out:
        RETURN(rc);
 }
 
-long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+static long
+ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct inode            *inode = file->f_dentry->d_inode;
        struct ll_file_data     *fd = LUSTRE_FPRIVATE(file);
@@ -2682,7 +2693,7 @@ generic_file_llseek_size(struct file *file, loff_t offset, int origin,
 }
 #endif
 
-loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
+static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
 {
        struct inode *inode = file->f_dentry->d_inode;
        loff_t retval, eof = 0;
@@ -2707,7 +2718,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
        RETURN(retval);
 }
 
-int ll_flush(struct file *file, fl_owner_t id)
+static int ll_flush(struct file *file, fl_owner_t id)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct ll_inode_info *lli = ll_i2info(inode);
@@ -2865,7 +2876,8 @@ int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
        RETURN(rc);
 }
 
-int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
+static int
+ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
 {
        struct inode *inode = file->f_dentry->d_inode;
        struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -3102,7 +3114,8 @@ out_free:
        RETURN(rc);
 }
 
-int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
+static int
+ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
 {
         ENTRY;
 
@@ -3198,8 +3211,7 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc)
        return rc;
 }
 
-int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
-                             __u64 ibits)
+static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 {
         struct inode *inode = dentry->d_inode;
         struct ptlrpc_request *req = NULL;
@@ -3316,14 +3328,14 @@ static int ll_merge_md_attr(struct inode *inode)
        RETURN(0);
 }
 
-int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
-                          __u64 ibits)
+static int
+ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 {
        struct inode    *inode = dentry->d_inode;
        int              rc;
        ENTRY;
 
-       rc = __ll_inode_revalidate_it(dentry, it, ibits);
+       rc = __ll_inode_revalidate(dentry, ibits);
        if (rc != 0)
                RETURN(rc);
 
@@ -3353,16 +3365,15 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
        RETURN(rc);
 }
 
-int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
-                  struct lookup_intent *it, struct kstat *stat)
+int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
 {
         struct inode *inode = de->d_inode;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ll_inode_info *lli = ll_i2info(inode);
         int res = 0;
 
-        res = ll_inode_revalidate_it(de, it, MDS_INODELOCK_UPDATE |
-                                             MDS_INODELOCK_LOOKUP);
+       res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE |
+                                     MDS_INODELOCK_LOOKUP);
         ll_stats_ops_tally(sbi, LPROC_LL_GETATTR, 1);
 
         if (res)
@@ -3394,15 +3405,9 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
 
         return 0;
 }
-int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
-{
-        struct lookup_intent it = { .it_op = IT_GETATTR };
-
-        return ll_getattr_it(mnt, de, &it, stat);
-}
 
-int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
-                __u64 start, __u64 len)
+static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+                    __u64 start, __u64 len)
 {
         int rc;
         size_t num_bytes;
@@ -3434,7 +3439,7 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
         return rc;
 }
 
-struct posix_acl * ll_get_acl(struct inode *inode, int type)
+struct posix_acl *ll_get_acl(struct inode *inode, int type)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        struct posix_acl *acl = NULL;
@@ -3505,10 +3510,8 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
         * need to do it before permission check. */
 
         if (inode == inode->i_sb->s_root->d_inode) {
-                struct lookup_intent it = { .it_op = IT_LOOKUP };
-
-                rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it,
-                                              MDS_INODELOCK_LOOKUP);
+               rc = __ll_inode_revalidate(inode->i_sb->s_root,
+                                          MDS_INODELOCK_LOOKUP);
                 if (rc)
                         RETURN(rc);
         }
@@ -3663,8 +3666,9 @@ void ll_iocontrol_unregister(void *magic)
 EXPORT_SYMBOL(ll_iocontrol_register);
 EXPORT_SYMBOL(ll_iocontrol_unregister);
 
-enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file,
-                        unsigned int cmd, unsigned long arg, int *rcp)
+static enum llioc_iter
+ll_iocontrol_call(struct inode *inode, struct file *file,
+                 unsigned int cmd, unsigned long arg, int *rcp)
 {
         enum llioc_iter ret = LLIOC_CONT;
         struct llioc_data *data;
@@ -3714,11 +3718,24 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf)
                LASSERT(lock != NULL);
                LASSERT(ldlm_has_layout(lock));
                if (result == 0) {
+                       struct lustre_md *md = conf->u.coc_md;
+                       __u32 gen = LL_LAYOUT_GEN_EMPTY;
+
                        /* it can only be allowed to match after layout is
                         * applied to inode otherwise false layout would be
                         * seen. Applying layout shoud happen before dropping
                         * the intent lock. */
                        ldlm_lock_allow_match(lock);
+
+                       lli->lli_has_smd = lsm_has_objects(md->lsm);
+                       if (md->lsm != NULL)
+                               gen = md->lsm->lsm_layout_gen;
+
+                       CDEBUG(D_VFSTRACE,
+                              DFID ": layout version change: %u -> %u\n",
+                              PFID(&lli->lli_fid), ll_layout_version_get(lli),
+                              gen);
+                       ll_layout_version_set(lli, gen);
                }
        }
        RETURN(result);