Whamcloud - gitweb
LU-2689 interop: use stripe md in ll_update_inode()
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index fe87c92..6e91365 100644 (file)
@@ -94,11 +94,7 @@ static struct ll_sb_info *ll_init_sbi(void)
         si_meminfo(&si);
         pages = si.totalram - si.totalhigh;
         if (pages >> (20 - CFS_PAGE_SHIFT) < 512) {
-#ifdef HAVE_BGL_SUPPORT
-               lru_page_max = pages / 4;
-#else
                lru_page_max = pages / 2;
-#endif
        } else {
                lru_page_max = (pages / 4) * 3;
        }
@@ -222,7 +218,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                   OBD_CONNECT_FULL20   | OBD_CONNECT_64BITHASH|
                                  OBD_CONNECT_EINPROGRESS |
                                  OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE |
-                                 OBD_CONNECT_LAYOUTLOCK;
+                                 OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_PINGLESS;
 
         if (sbi->ll_flags & LL_SBI_SOM_PREVIEW)
                 data->ocd_connect_flags |= OBD_CONNECT_SOM;
@@ -268,7 +264,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
                 data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE;
 
-        data->ocd_brw_size = PTLRPC_MAX_BRW_SIZE;
+       data->ocd_brw_size = MD_MAX_BRW_SIZE;
 
         err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL);
         if (err == -EBUSY) {
@@ -282,8 +278,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 GOTO(out, err);
         }
 
+       sbi->ll_md_exp->exp_connect_data = *data;
+
+       /* For mount, we only need fs info from MDT0, and also in DNE, it
+        * can make sure the client can be mounted as long as MDT0 is
+        * avaible */
        err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
-                        cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0);
+                       cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+                       OBD_STATFS_FOR_MDT0);
        if (err)
                GOTO(out_md, err);
 
@@ -294,8 +296,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         * be non-zero, but if accessing an upgraded 2.1 server it will
         * have the correct flags filled in.
         * XXX: fill in the LMV exp_connect_flags from MDC(s). */
-       valid = sbi->ll_md_exp->exp_connect_flags & CLIENT_CONNECT_MDT_REQD;
-       if (sbi->ll_md_exp->exp_connect_flags != 0 &&
+       valid = exp_connect_flags(sbi->ll_md_exp) & CLIENT_CONNECT_MDT_REQD;
+       if (exp_connect_flags(sbi->ll_md_exp) != 0 &&
            valid != CLIENT_CONNECT_MDT_REQD) {
                char *buf;
 
@@ -320,7 +322,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                GOTO(out_md, err);
        }
 
-        LASSERT(osfs->os_bsize);
+       LASSERT(osfs->os_bsize);
         sb->s_blocksize = osfs->os_bsize;
         sb->s_blocksize_bits = log2(osfs->os_bsize);
         sb->s_magic = LL_SUPER_MAGIC;
@@ -374,10 +376,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         if (data->ocd_connect_flags & OBD_CONNECT_64BITHASH)
                 sbi->ll_flags |= LL_SBI_64BIT_HASH;
 
-        if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE)
-                sbi->ll_md_brw_size = data->ocd_brw_size;
-        else
-                sbi->ll_md_brw_size = CFS_PAGE_SIZE;
+       if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE)
+               sbi->ll_md_brw_size = data->ocd_brw_size;
+       else
+               sbi->ll_md_brw_size = CFS_PAGE_SIZE;
 
        if (data->ocd_connect_flags & OBD_CONNECT_LAYOUTLOCK) {
                LCONSOLE_INFO("Layout lock feature supported.\n");
@@ -400,7 +402,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                                   OBD_CONNECT_MAXBYTES |
                                  OBD_CONNECT_EINPROGRESS |
                                  OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE |
-                                 OBD_CONNECT_LAYOUTLOCK;
+                                 OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_PINGLESS;
 
         if (sbi->ll_flags & LL_SBI_SOM_PREVIEW)
                 data->ocd_connect_flags |= OBD_CONNECT_SOM;
@@ -431,7 +433,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
         obd->obd_upcall.onu_owner = &sbi->ll_lco;
         obd->obd_upcall.onu_upcall = cl_ocd_update;
 
-        data->ocd_brw_size = PTLRPC_MAX_BRW_SIZE;
+       data->ocd_brw_size = DT_MAX_BRW_SIZE;
 
        err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data,
                          NULL);
@@ -447,6 +449,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                GOTO(out_md, err);
        }
 
+       sbi->ll_dt_exp->exp_connect_data = *data;
+
        mutex_lock(&sbi->ll_lco.lco_lock);
        sbi->ll_lco.lco_flags = data->ocd_connect_flags;
        sbi->ll_lco.lco_md_exp = sbi->ll_md_exp;
@@ -912,7 +916,7 @@ void ll_lli_init(struct ll_inode_info *lli)
        mutex_init(&lli->lli_och_mutex);
        spin_lock_init(&lli->lli_agl_lock);
        lli->lli_has_smd = false;
-       lli->lli_layout_gen = LL_LAYOUT_GEN_ZERO;
+       lli->lli_layout_gen = LL_LAYOUT_GEN_NONE;
        lli->lli_clob = NULL;
 
        LASSERT(lli->lli_vfs_inode.i_mode != 0);
@@ -934,6 +938,7 @@ void ll_lli_init(struct ll_inode_info *lli)
                CFS_INIT_LIST_HEAD(&lli->lli_agl_list);
                lli->lli_agl_index = 0;
                lli->lli_async_rc = 0;
+               lli->lli_volatile = false;
        }
        mutex_init(&lli->lli_layout_mutex);
 }
@@ -986,14 +991,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
         if (err)
                 GOTO(out_free, err);
 
-        err = ll_bdi_init(&lsi->lsi_bdi);
-        if (err)
-                GOTO(out_free, err);
-        lsi->lsi_flags |= LSI_BDI_INITIALIZED;
-        lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
-        err = ll_bdi_register(&lsi->lsi_bdi);
-        if (err)
-                GOTO(out_free, err);
+       err = bdi_init(&lsi->lsi_bdi);
+       if (err)
+               GOTO(out_free, err);
+       lsi->lsi_flags |= LSI_BDI_INITIALIZED;
+       lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
+       err = ll_bdi_register(&lsi->lsi_bdi);
+       if (err)
+               GOTO(out_free, err);
 
 #ifdef HAVE_SB_BDI
         sb->s_bdi = &lsi->lsi_bdi;
@@ -1102,10 +1107,10 @@ void ll_put_super(struct super_block *sb)
         if (profilenm)
                 class_del_profile(profilenm);
 
-        if (lsi->lsi_flags & LSI_BDI_INITIALIZED) {
-                ll_bdi_destroy(&lsi->lsi_bdi);
-                lsi->lsi_flags &= ~LSI_BDI_INITIALIZED;
-        }
+       if (lsi->lsi_flags & LSI_BDI_INITIALIZED) {
+               bdi_destroy(&lsi->lsi_bdi);
+               lsi->lsi_flags &= ~LSI_BDI_INITIALIZED;
+       }
 
         ll_free_sbi(sb);
         lsi->lsi_llsbi = NULL;
@@ -1474,9 +1479,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr)
                        inode_dio_write_done(inode);
                mutex_unlock(&inode->i_mutex);
                down_write(&lli->lli_trunc_sem);
-               mutex_lock(&inode->i_mutex);
-               if (ia_valid & ATTR_SIZE)
-                       inode_dio_wait(inode);
        }
 
        /* We need a steady stripe configuration for setattr to avoid
@@ -1534,13 +1536,17 @@ out:
                 }
                 ll_finish_md_op_data(op_data);
         }
-        if (!S_ISDIR(inode->i_mode))
+       if (!S_ISDIR(inode->i_mode)) {
                up_write(&lli->lli_trunc_sem);
+               mutex_lock(&inode->i_mutex);
+               if (ia_valid & ATTR_SIZE)
+                       inode_dio_wait(inode);
+       }
 
-        ll_stats_ops_tally(ll_i2sbi(inode), (ia_valid & ATTR_SIZE) ?
-                           LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1);
+       ll_stats_ops_tally(ll_i2sbi(inode), (ia_valid & ATTR_SIZE) ?
+                       LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1);
 
-        return rc;
+       return rc;
 }
 
 int ll_setattr(struct dentry *de, struct iattr *attr)
@@ -1691,6 +1697,10 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 
        LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
        if (lsm != NULL) {
+               if (!lli->lli_has_smd &&
+                   !(sbi->ll_flags & LL_SBI_LAYOUT_LOCK))
+                       cl_file_inode_init(inode, md);
+
                lli->lli_maxbytes = lsm->lsm_maxbytes;
                if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
                        lli->lli_maxbytes = MAX_LFS_FILESIZE;
@@ -2292,17 +2302,21 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
                 op_data->op_capa2 = NULL;
         }
 
-        op_data->op_name = name;
-        op_data->op_namelen = namelen;
-        op_data->op_mode = mode;
-        op_data->op_mod_time = cfs_time_current_sec();
-        op_data->op_fsuid = cfs_curproc_fsuid();
-        op_data->op_fsgid = cfs_curproc_fsgid();
-        op_data->op_cap = cfs_curproc_cap_pack();
-        op_data->op_bias = MDS_CHECK_SPLIT;
-        op_data->op_opc = opc;
-        op_data->op_mds = 0;
-        op_data->op_data = data;
+       op_data->op_name = name;
+       op_data->op_namelen = namelen;
+       op_data->op_mode = mode;
+       op_data->op_mod_time = cfs_time_current_sec();
+       op_data->op_fsuid = cfs_curproc_fsuid();
+       op_data->op_fsgid = cfs_curproc_fsgid();
+       op_data->op_cap = cfs_curproc_cap_pack();
+       op_data->op_bias = 0;
+       op_data->op_cli_flags = 0;
+       if ((opc == LUSTRE_OPC_CREATE) && (name != NULL) &&
+            filename_is_volatile(name, namelen, NULL))
+               op_data->op_bias |= MDS_CREATE_VOLATILE;
+       op_data->op_opc = opc;
+       op_data->op_mds = 0;
+       op_data->op_data = data;
 
         /* If the file is being opened after mknod() (normally due to NFS)
          * try to use the default stripe data from parent directory for