Whamcloud - gitweb
LU-14677 sec: migrate/extend/split on encrypted file
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index 819c072..d0597f2 100644 (file)
@@ -187,6 +187,7 @@ static struct ll_sb_info *ll_init_sbi(void)
        sbi->ll_flags |= LL_SBI_AGL_ENABLED;
        sbi->ll_flags |= LL_SBI_FAST_READ;
        sbi->ll_flags |= LL_SBI_TINY_WRITE;
+       sbi->ll_flags |= LL_SBI_PARALLEL_DIO;
        ll_sbi_set_encrypt(sbi, true);
 
        /* root squash */
@@ -336,7 +337,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                                   OBD_CONNECT2_CRUSH | OBD_CONNECT2_LSEEK |
                                   OBD_CONNECT2_GETATTR_PFID |
                                   OBD_CONNECT2_DOM_LVB |
-                                  OBD_CONNECT2_REP_MBITS;
+                                  OBD_CONNECT2_REP_MBITS |
+                                  OBD_CONNECT2_ATOMIC_OPEN_LOCK;
 
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
@@ -1478,12 +1480,15 @@ static struct inode *ll_iget_anon_dir(struct super_block *sb,
                                      const struct lu_fid *fid,
                                      struct lustre_md *md)
 {
-       struct ll_sb_info       *sbi = ll_s2sbi(sb);
-       struct mdt_body         *body = md->body;
-       struct inode            *inode;
-       ino_t                   ino;
+       struct ll_sb_info *sbi = ll_s2sbi(sb);
+       struct ll_inode_info *lli;
+       struct mdt_body *body = md->body;
+       struct inode *inode;
+       ino_t ino;
+
        ENTRY;
 
+       LASSERT(md->lmv);
        ino = cl_fid_build_ino(fid, sbi->ll_flags & LL_SBI_32BIT_API);
        inode = iget_locked(sb, ino);
        if (inode == NULL) {
@@ -1492,10 +1497,8 @@ static struct inode *ll_iget_anon_dir(struct super_block *sb,
                RETURN(ERR_PTR(-ENOENT));
        }
 
+       lli = ll_i2info(inode);
        if (inode->i_state & I_NEW) {
-               struct ll_inode_info *lli = ll_i2info(inode);
-               struct lmv_stripe_md *lsm = md->lmv;
-
                inode->i_mode = (inode->i_mode & ~S_IFMT) |
                                (body->mbo_mode & S_IFMT);
                LASSERTF(S_ISDIR(inode->i_mode), "Not slave inode "DFID"\n",
@@ -1516,12 +1519,17 @@ static struct inode *ll_iget_anon_dir(struct super_block *sb,
                lli->lli_fid = *fid;
                ll_lli_init(lli);
 
-               LASSERT(lsm != NULL);
                /* master object FID */
                lli->lli_pfid = body->mbo_fid1;
                CDEBUG(D_INODE, "lli %p slave "DFID" master "DFID"\n",
                       lli, PFID(fid), PFID(&lli->lli_pfid));
                unlock_new_inode(inode);
+       } else {
+               /* in directory restripe/auto-split, a directory will be
+                * transformed to a stripe if it's plain, set its pfid here,
+                * otherwise ll_lock_cancel_bits() can't find the master inode.
+                */
+               lli->lli_pfid = body->mbo_fid1;
        }
 
        RETURN(inode);
@@ -1630,6 +1638,12 @@ static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
        if (md->default_lmv)
                ll_update_default_lsm_md(inode, md);
 
+       /* after dir migration/restripe, a stripe may be turned into a
+        * directory, in this case, zero out its lli_pfid.
+        */
+       if (unlikely(fid_is_norm(&lli->lli_pfid)))
+               fid_zero(&lli->lli_pfid);
+
        /*
         * no striped information from request, lustre_md from req does not
         * include stripeEA, see ll_md_setattr()
@@ -2133,8 +2147,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
                         * it is necessary due to possible time
                         * de-synchronization between MDT inode and OST objects
                         */
-                       if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode) &&
-                           attr->ia_valid & ATTR_SIZE) {
+                       if (S_ISREG(inode->i_mode) && IS_ENCRYPTED(inode)) {
                                xvalid |= OP_XVALID_FLAGS;
                                flags = LUSTRE_ENCRYPT_FL;
                                /* Call to ll_io_zero_page is not necessary if
@@ -2143,7 +2156,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
                                 * In case of Direct IO, all we need is to set
                                 * new size.
                                 */
-                               if (attr->ia_size & ~PAGE_MASK &&
+                               if (attr->ia_valid & ATTR_SIZE &&
+                                   attr->ia_size & ~PAGE_MASK &&
                                    !(attr->ia_valid & ATTR_FILE &&
                                      attr->ia_file->f_flags & O_DIRECT)) {
                                        pgoff_t offset =
@@ -2702,7 +2716,8 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                if (flags & LUSTRE_PROJINHERIT_FL)
                        fa.fsx_xflags = FS_XFLAG_PROJINHERIT;
 
-               rc = ll_ioctl_check_project(inode, &fa);
+               rc = ll_ioctl_check_project(inode, fa.fsx_xflags,
+                                           fa.fsx_projid);
                if (rc)
                        RETURN(rc);