]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
staging: lustre: llite: a few fixes for migration.
authorwang di <di.wang@intel.com>
Tue, 16 Aug 2016 20:18:35 +0000 (16:18 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2016 13:57:35 +0000 (15:57 +0200)
1. Clear the client dentry cache before migrating file/directory
   to the remote MDT.

2. Do not return stripe information to client, if it did not get
   the layout lock.

Signed-off-by: wang di <di.wang@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4682
Reviewed-on: http://review.whamcloud.com/9522
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/dir.c
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_internal.h
drivers/staging/lustre/lustre/lov/lov_object.c

index ef7322e3fc93d6ff494247fae73bec785051b968..84bec03a2a970c7ad5e16716d785bd050afb2971 100644 (file)
@@ -1318,11 +1318,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                return 0;
        }
        case IOC_MDC_LOOKUP: {
-               struct ptlrpc_request *request = NULL;
                int namelen, len = 0;
                char *buf = NULL;
                char *filename;
-               struct md_op_data *op_data;
 
                rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
                if (rc)
@@ -1338,21 +1336,13 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                        goto out_free;
                }
 
-               op_data = ll_prep_md_op_data(NULL, inode, NULL, filename, namelen,
-                                            0, LUSTRE_OPC_ANY, NULL);
-               if (IS_ERR(op_data)) {
-                       rc = PTR_ERR(op_data);
-                       goto out_free;
-               }
-
-               op_data->op_valid = OBD_MD_FLID;
-               rc = md_getattr_name(sbi->ll_md_exp, op_data, &request);
-               ll_finish_md_op_data(op_data);
+               rc = ll_get_fid_by_name(inode, filename, namelen, NULL);
                if (rc < 0) {
-                       CDEBUG(D_INFO, "md_getattr_name: %d\n", rc);
+                       CERROR("%s: lookup %.*s failed: rc = %d\n",
+                              ll_get_fsname(inode->i_sb, NULL, 0), namelen,
+                              filename, rc);
                        goto out_free;
                }
-               ptlrpc_req_finished(request);
 out_free:
                obd_ioctl_freedata(buf, len);
                return rc;
@@ -1981,7 +1971,7 @@ out_quotactl:
 
                filename = data->ioc_inlbuf1;
                namelen = data->ioc_inllen1;
-               if (namelen < 1) {
+               if (namelen < 1 || namelen != strlen(filename) + 1) {
                        rc = -EINVAL;
                        goto migrate_free;
                }
@@ -1992,7 +1982,7 @@ out_quotactl:
                }
                mdtidx = *(int *)data->ioc_inlbuf2;
 
-               rc = ll_migrate(inode, file, mdtidx, filename, namelen);
+               rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1);
 migrate_free:
                obd_ioctl_freedata(buf, len);
 
index 8d98db607d0f634fde6126401f9a93f0ed18b839..769b0289a2df6115f96b1948d2762116029623ff 100644 (file)
@@ -2828,8 +2828,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
        return rc;
 }
 
-static int ll_get_fid_by_name(struct inode *parent, const char *name,
-                             int namelen, struct lu_fid *fid)
+int ll_get_fid_by_name(struct inode *parent, const char *name,
+                      int namelen, struct lu_fid *fid)
 {
        struct md_op_data *op_data = NULL;
        struct ptlrpc_request *req;
@@ -2843,20 +2843,19 @@ static int ll_get_fid_by_name(struct inode *parent, const char *name,
 
        op_data->op_valid = OBD_MD_FLID;
        rc = md_getattr_name(ll_i2sbi(parent)->ll_md_exp, op_data, &req);
+       ll_finish_md_op_data(op_data);
        if (rc < 0)
-               goto out_free;
+               return rc;
 
        body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
        if (!body) {
                rc = -EFAULT;
                goto out_req;
        }
-       *fid = body->fid1;
+       if (fid)
+               *fid = body->fid1;
 out_req:
        ptlrpc_req_finished(req);
-out_free:
-       if (op_data)
-               ll_finish_md_op_data(op_data);
        return rc;
 }
 
@@ -2864,12 +2863,13 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
               const char *name, int namelen)
 {
        struct ptlrpc_request *request = NULL;
+       struct inode *child_inode = NULL;
        struct dentry *dchild = NULL;
        struct md_op_data *op_data;
        struct qstr qstr;
        int rc;
 
-       CDEBUG(D_VFSTRACE, "migrate %s under"DFID" to MDT%d\n",
+       CDEBUG(D_VFSTRACE, "migrate %s under "DFID" to MDT%d\n",
               name, PFID(ll_inode2fid(parent)), mdtidx);
 
        op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
@@ -2884,8 +2884,13 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
        dchild = d_lookup(file_dentry(file), &qstr);
        if (dchild && dchild->d_inode) {
                op_data->op_fid3 = *ll_inode2fid(dchild->d_inode);
+               if (dchild->d_inode) {
+                       child_inode = igrab(dchild->d_inode);
+                       ll_invalidate_aliases(child_inode);
+               }
+               dput(dchild);
        } else {
-               rc = ll_get_fid_by_name(parent, name, strnlen(name, namelen),
+               rc = ll_get_fid_by_name(parent, name, namelen,
                                        &op_data->op_fid3);
                if (rc)
                        goto out_free;
@@ -2895,6 +2900,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
                CERROR("%s: migrate %s, but fid "DFID" is insane\n",
                       ll_get_fsname(parent->i_sb, NULL, 0), name,
                       PFID(&op_data->op_fid3));
+               rc = -EINVAL;
                goto out_free;
        }
 
@@ -2912,18 +2918,16 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
        op_data->op_mds = mdtidx;
        op_data->op_cli_flags = CLI_MIGRATE;
        rc = md_rename(ll_i2sbi(parent)->ll_md_exp, op_data, name,
-                      strnlen(name, namelen), name, strnlen(name, namelen),
-                      &request);
+                      namelen, name, namelen, &request);
        if (!rc)
                ll_update_times(request, parent);
 
        ptlrpc_req_finished(request);
 
 out_free:
-       if (dchild) {
-               if (dchild->d_inode)
-                       ll_delete_inode(dchild->d_inode);
-               dput(dchild);
+       if (child_inode) {
+               clear_nlink(child_inode);
+               iput(child_inode);
        }
 
        ll_finish_md_op_data(op_data);
index 69492f082185b765bf4c7f4bc60cdf70e36a0b2d..120aca3ec271e9d75de93e40256cf8953c9589f8 100644 (file)
@@ -721,6 +721,8 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 struct posix_acl *ll_get_acl(struct inode *inode, int type);
 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
               const char *name, int namelen);
+int ll_get_fid_by_name(struct inode *parent, const char *name,
+                      int namelen, struct lu_fid *fid);
 int ll_inode_permission(struct inode *inode, int mask);
 
 int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
index f9621b0fd469ea2d9a13642eada7618d406d33f2..2a52d0c527990925d724e8074fda65a2ad822621 100644 (file)
@@ -224,6 +224,7 @@ static int lov_init_raid0(const struct lu_env *env,
 
        LASSERT(!lov->lo_lsm);
        lov->lo_lsm = lsm_addref(lsm);
+       lov->lo_layout_invalid = true;
        r0->lo_nr  = lsm->lsm_stripe_count;
        LASSERT(r0->lo_nr <= lov_targets_nr(dev));