Commit 34e1f2bb authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: llite: expand the GOTO macro

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier lbl;
@@

if (...)
  GOTO(lbl,...);
+else
GOTO(lbl,...);

@@
identifier lbl,rc;
constant c;
expression e,e1;
@@

if (
-   e
+   !e
   )
-  GOTO(lbl,\(rc\|c\));
-else GOTO(lbl,e1);
+  e1;
+goto lbl;

@@
identifier lbl,rc;
constant c;
expression e,e1;
@@

if (e)
-  GOTO(lbl,e1);
-else GOTO(lbl,\(rc\|c\));
+  e1;
+goto lbl;

@@
identifier lbl;
expression e,e1,e2;
@@

if (e)
-  GOTO(lbl,e1);
-else GOTO(lbl,e2);
+  e1;
+else e2;
+goto lbl;

// ------------------------------------------------------------------------

@@
identifier lbl,rc;
constant c;
@@

- GOTO(lbl,\(rc\|c\));
+ goto lbl;

@@
identifier lbl;
expression rc;
@@

- GOTO(lbl,rc);
+ rc;
+ goto lbl;
// </smpl>

The rules above the line deal with the case where the goto desination is
the same whether or not the the branch is taken.  In that case, the goto is
created in just one instance after the if.  This affects only the files
namei.c and llite_lib.c.
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ebcb9836
This diff is collapsed.
This diff is collapsed.
...@@ -543,7 +543,7 @@ static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) ...@@ -543,7 +543,7 @@ static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
"renewal failed: -EIO, " "renewal failed: -EIO, "
"retry in 2 mins"); "retry in 2 mins");
ll_capa_renewal_retries++; ll_capa_renewal_retries++;
GOTO(retry, rc); goto retry;
} else { } else {
DEBUG_CAPA(D_ERROR, &ocapa->c_capa, DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
"renewal failed(rc: %d) for", rc); "renewal failed(rc: %d) for", rc);
......
...@@ -155,7 +155,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, ...@@ -155,7 +155,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
inode = igrab(inode); inode = igrab(inode);
LASSERT(inode); LASSERT(inode);
GOTO(out, 0); goto out;
} }
if (flags & LLIF_DONE_WRITING) { if (flags & LLIF_DONE_WRITING) {
/* Some pages are still dirty, it is early to send /* Some pages are still dirty, it is early to send
...@@ -167,7 +167,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, ...@@ -167,7 +167,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
inode = igrab(inode); inode = igrab(inode);
LASSERT(inode); LASSERT(inode);
GOTO(out, 0); goto out;
} }
} }
CDEBUG(D_INODE, "Epoch %llu closed on "DFID"\n", CDEBUG(D_INODE, "Epoch %llu closed on "DFID"\n",
...@@ -184,14 +184,14 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, ...@@ -184,14 +184,14 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
/* Pack Size-on-MDS inode attributes only if they has changed */ /* Pack Size-on-MDS inode attributes only if they has changed */
if (!(lli->lli_flags & LLIF_SOM_DIRTY)) { if (!(lli->lli_flags & LLIF_SOM_DIRTY)) {
spin_unlock(&lli->lli_lock); spin_unlock(&lli->lli_lock);
GOTO(out, 0); goto out;
} }
/* There is a pending DONE_WRITE -- close epoch with no /* There is a pending DONE_WRITE -- close epoch with no
* attribute change. */ * attribute change. */
if (lli->lli_flags & LLIF_EPOCH_PENDING) { if (lli->lli_flags & LLIF_EPOCH_PENDING) {
spin_unlock(&lli->lli_lock); spin_unlock(&lli->lli_lock);
GOTO(out, 0); goto out;
} }
} }
...@@ -294,7 +294,7 @@ static void ll_done_writing(struct inode *inode) ...@@ -294,7 +294,7 @@ static void ll_done_writing(struct inode *inode)
ll_prepare_done_writing(inode, op_data, &och); ll_prepare_done_writing(inode, op_data, &och);
/* If there is no @och, we do not do D_W yet. */ /* If there is no @och, we do not do D_W yet. */
if (och == NULL) if (och == NULL)
GOTO(out, 0); goto out;
rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL); rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL);
if (rc == -EAGAIN) { if (rc == -EAGAIN) {
......
...@@ -256,10 +256,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -256,10 +256,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"recovery, of which this client is not a " "recovery, of which this client is not a "
"part. Please wait for recovery to complete," "part. Please wait for recovery to complete,"
" abort, or time out.\n", md); " abort, or time out.\n", md);
GOTO(out, err); goto out;
} else if (err) { } else if (err) {
CERROR("cannot connect to %s: rc = %d\n", md, err); CERROR("cannot connect to %s: rc = %d\n", md, err);
GOTO(out, err); goto out;
} }
sbi->ll_md_exp->exp_connect_data = *data; sbi->ll_md_exp->exp_connect_data = *data;
...@@ -269,7 +269,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -269,7 +269,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) { if (err) {
CERROR("%s: Can't init metadata layer FID infrastructure, " CERROR("%s: Can't init metadata layer FID infrastructure, "
"rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); "rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err);
GOTO(out_md, err); goto out_md;
} }
/* For mount, we only need fs info from MDT0, and also in DNE, it /* For mount, we only need fs info from MDT0, and also in DNE, it
...@@ -279,7 +279,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -279,7 +279,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_FOR_MDT0); OBD_STATFS_FOR_MDT0);
if (err) if (err)
GOTO(out_md_fid, err); goto out_md_fid;
/* This needs to be after statfs to ensure connect has finished. /* This needs to be after statfs to ensure connect has finished.
* Note that "data" does NOT contain the valid connect reply. * Note that "data" does NOT contain the valid connect reply.
...@@ -302,7 +302,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -302,7 +302,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"server or downgrade client.\n", "server or downgrade client.\n",
sbi->ll_md_exp->exp_obd->obd_name, buf); sbi->ll_md_exp->exp_obd->obd_name, buf);
OBD_FREE(buf, PAGE_CACHE_SIZE); OBD_FREE(buf, PAGE_CACHE_SIZE);
GOTO(out_md_fid, err = -EPROTO); err = -EPROTO;
goto out_md_fid;
} }
size = sizeof(*data); size = sizeof(*data);
...@@ -311,7 +312,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -311,7 +312,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) { if (err) {
CERROR("%s: Get connect data failed: rc = %d\n", CERROR("%s: Get connect data failed: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err); sbi->ll_md_exp->exp_obd->obd_name, err);
GOTO(out_md_fid, err); goto out_md_fid;
} }
LASSERT(osfs->os_bsize); LASSERT(osfs->os_bsize);
...@@ -392,7 +393,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -392,7 +393,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
obd = class_name2obd(dt); obd = class_name2obd(dt);
if (!obd) { if (!obd) {
CERROR("DT %s: not setup or attached\n", dt); CERROR("DT %s: not setup or attached\n", dt);
GOTO(out_md_fid, err = -ENODEV); err = -ENODEV;
goto out_md_fid;
} }
data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION | data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION |
...@@ -443,11 +445,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -443,11 +445,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"recovery, of which this client is not a " "recovery, of which this client is not a "
"part. Please wait for recovery to " "part. Please wait for recovery to "
"complete, abort, or time out.\n", dt); "complete, abort, or time out.\n", dt);
GOTO(out_md, err); goto out_md;
} else if (err) { } else if (err) {
CERROR("%s: Cannot connect to %s: rc = %d\n", CERROR("%s: Cannot connect to %s: rc = %d\n",
sbi->ll_dt_exp->exp_obd->obd_name, dt, err); sbi->ll_dt_exp->exp_obd->obd_name, dt, err);
GOTO(out_md, err); goto out_md;
} }
sbi->ll_dt_exp->exp_connect_data = *data; sbi->ll_dt_exp->exp_connect_data = *data;
...@@ -457,7 +459,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -457,7 +459,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) { if (err) {
CERROR("%s: Can't init data layer FID infrastructure, " CERROR("%s: Can't init data layer FID infrastructure, "
"rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, err); "rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, err);
GOTO(out_dt, err); goto out_dt;
} }
mutex_lock(&sbi->ll_lco.lco_lock); mutex_lock(&sbi->ll_lco.lco_lock);
...@@ -470,13 +472,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -470,13 +472,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, &oc); err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, &oc);
if (err) { if (err) {
CERROR("cannot mds_connect: rc = %d\n", err); CERROR("cannot mds_connect: rc = %d\n", err);
GOTO(out_lock_cn_cb, err); goto out_lock_cn_cb;
} }
if (!fid_is_sane(&sbi->ll_root_fid)) { if (!fid_is_sane(&sbi->ll_root_fid)) {
CERROR("%s: Invalid root fid "DFID" during mount\n", CERROR("%s: Invalid root fid "DFID" during mount\n",
sbi->ll_md_exp->exp_obd->obd_name, sbi->ll_md_exp->exp_obd->obd_name,
PFID(&sbi->ll_root_fid)); PFID(&sbi->ll_root_fid));
GOTO(out_lock_cn_cb, err = -EINVAL); err = -EINVAL;
goto out_lock_cn_cb;
} }
CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
...@@ -494,8 +497,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -494,8 +497,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
valid |= OBD_MD_FLACL; valid |= OBD_MD_FLACL;
OBD_ALLOC_PTR(op_data); OBD_ALLOC_PTR(op_data);
if (op_data == NULL) if (op_data == NULL) {
GOTO(out_lock_cn_cb, err = -ENOMEM); err = -ENOMEM;
goto out_lock_cn_cb;
}
op_data->op_fid1 = sbi->ll_root_fid; op_data->op_fid1 = sbi->ll_root_fid;
op_data->op_mode = 0; op_data->op_mode = 0;
...@@ -509,7 +514,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -509,7 +514,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) { if (err) {
CERROR("%s: md_getattr failed for root: rc = %d\n", CERROR("%s: md_getattr failed for root: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err); sbi->ll_md_exp->exp_obd->obd_name, err);
GOTO(out_lock_cn_cb, err); goto out_lock_cn_cb;
} }
err = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp, err = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp,
...@@ -517,7 +522,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -517,7 +522,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) { if (err) {
CERROR("failed to understand root inode md: rc = %d\n", err); CERROR("failed to understand root inode md: rc = %d\n", err);
ptlrpc_req_finished(request); ptlrpc_req_finished(request);
GOTO(out_lock_cn_cb, err); goto out_lock_cn_cb;
} }
LASSERT(fid_is_sane(&sbi->ll_root_fid)); LASSERT(fid_is_sane(&sbi->ll_root_fid));
...@@ -539,13 +544,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -539,13 +544,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
err = IS_ERR(root) ? PTR_ERR(root) : -EBADF; err = IS_ERR(root) ? PTR_ERR(root) : -EBADF;
root = NULL; root = NULL;
CERROR("lustre_lite: bad iget4 for root\n"); CERROR("lustre_lite: bad iget4 for root\n");
GOTO(out_root, err); goto out_root;
} }
err = ll_close_thread_start(&sbi->ll_lcq); err = ll_close_thread_start(&sbi->ll_lcq);
if (err) { if (err) {
CERROR("cannot start close thread: rc %d\n", err); CERROR("cannot start close thread: rc %d\n", err);
GOTO(out_root, err); goto out_root;
} }
#ifdef CONFIG_FS_POSIX_ACL #ifdef CONFIG_FS_POSIX_ACL
...@@ -569,7 +574,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -569,7 +574,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (sb->s_root == NULL) { if (sb->s_root == NULL) {
CERROR("%s: can't make root dentry\n", CERROR("%s: can't make root dentry\n",
ll_get_fsname(sb, NULL, 0)); ll_get_fsname(sb, NULL, 0));
GOTO(out_root, err = -ENOMEM); err = -ENOMEM;
goto out_root;
} }
sbi->ll_sdev_orig = sb->s_dev; sbi->ll_sdev_orig = sb->s_dev;
...@@ -1003,16 +1009,16 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -1003,16 +1009,16 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags);
if (err) if (err)
GOTO(out_free, err); goto out_free;
err = bdi_init(&lsi->lsi_bdi); err = bdi_init(&lsi->lsi_bdi);
if (err) if (err)
GOTO(out_free, err); goto out_free;
lsi->lsi_flags |= LSI_BDI_INITIALIZED; lsi->lsi_flags |= LSI_BDI_INITIALIZED;
lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY; lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
err = ll_bdi_register(&lsi->lsi_bdi); err = ll_bdi_register(&lsi->lsi_bdi);
if (err) if (err)
GOTO(out_free, err); goto out_free;
sb->s_bdi = &lsi->lsi_bdi; sb->s_bdi = &lsi->lsi_bdi;
/* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
...@@ -1028,7 +1034,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -1028,7 +1034,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = lustre_process_log(sb, profilenm, cfg); err = lustre_process_log(sb, profilenm, cfg);
if (err < 0) { if (err < 0) {
CERROR("Unable to process log: %d\n", err); CERROR("Unable to process log: %d\n", err);
GOTO(out_free, err); goto out_free;
} }
/* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */ /* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */
...@@ -1037,19 +1043,24 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -1037,19 +1043,24 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be" LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be"
" read from the MGS. Does that filesystem " " read from the MGS. Does that filesystem "
"exist?\n", profilenm); "exist?\n", profilenm);
GOTO(out_free, err = -EINVAL); err = -EINVAL;
goto out_free;
} }
CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_md, lprof->lp_dt); lprof->lp_md, lprof->lp_dt);
OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2); OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2);
if (!dt) if (!dt) {
GOTO(out_free, err = -ENOMEM); err = -ENOMEM;
goto out_free;
}
sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance); sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2); OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2);
if (!md) if (!md) {
GOTO(out_free, err = -ENOMEM); err = -ENOMEM;
goto out_free;
}
sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance); sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
/* connections, registrations, sb setup */ /* connections, registrations, sb setup */
...@@ -1467,14 +1478,15 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1467,14 +1478,15 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
rc = ll_md_setattr(dentry, op_data, &mod); rc = ll_md_setattr(dentry, op_data, &mod);
if (rc) if (rc)
GOTO(out, rc); goto out;
/* truncate failed (only when non HSM import), others succeed */ /* truncate failed (only when non HSM import), others succeed */
if (file_is_released) { if (file_is_released) {
if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
GOTO(out, rc = -ENODATA); rc = -ENODATA;
else else
GOTO(out, rc = 0); rc = 0;
goto out;
} }
/* RPC to MDT is sent, cancel data modification flag */ /* RPC to MDT is sent, cancel data modification flag */
...@@ -1485,8 +1497,10 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1485,8 +1497,10 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
} }
ll_ioepoch_open(lli, op_data->op_ioepoch); ll_ioepoch_open(lli, op_data->op_ioepoch);
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode)) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
if (attr->ia_valid & (ATTR_SIZE | if (attr->ia_valid & (ATTR_SIZE |
ATTR_ATIME | ATTR_ATIME_SET | ATTR_ATIME | ATTR_ATIME_SET |
...@@ -2103,7 +2117,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, ...@@ -2103,7 +2117,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
rc = IS_ERR(*inode) ? PTR_ERR(*inode) : -ENOMEM; rc = IS_ERR(*inode) ? PTR_ERR(*inode) : -ENOMEM;
*inode = NULL; *inode = NULL;
CERROR("new_inode -fatal: rc %d\n", rc); CERROR("new_inode -fatal: rc %d\n", rc);
GOTO(out, rc); goto out;
} }
} }
...@@ -2152,36 +2166,44 @@ int ll_obd_statfs(struct inode *inode, void *arg) ...@@ -2152,36 +2166,44 @@ int ll_obd_statfs(struct inode *inode, void *arg)
__u32 flags; __u32 flags;
int len = 0, rc; int len = 0, rc;
if (!inode || !(sbi = ll_i2sbi(inode))) if (!inode || !(sbi = ll_i2sbi(inode))) {
GOTO(out_statfs, rc = -EINVAL); rc = -EINVAL;
goto out_statfs;
}
rc = obd_ioctl_getdata(&buf, &len, arg); rc = obd_ioctl_getdata(&buf, &len, arg);
if (rc) if (rc)
GOTO(out_statfs, rc); goto out_statfs;
data = (void*)buf; data = (void*)buf;
if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 || if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
!data->ioc_pbuf1 || !data->ioc_pbuf2) !data->ioc_pbuf1 || !data->ioc_pbuf2) {
GOTO(out_statfs, rc = -EINVAL); rc = -EINVAL;
goto out_statfs;
}
if (data->ioc_inllen1 != sizeof(__u32) || if (data->ioc_inllen1 != sizeof(__u32) ||
data->ioc_inllen2 != sizeof(__u32) || data->ioc_inllen2 != sizeof(__u32) ||
data->ioc_plen1 != sizeof(struct obd_statfs) || data->ioc_plen1 != sizeof(struct obd_statfs) ||
data->ioc_plen2 != sizeof(struct obd_uuid)) data->ioc_plen2 != sizeof(struct obd_uuid)) {
GOTO(out_statfs, rc = -EINVAL); rc = -EINVAL;
goto out_statfs;
}
memcpy(&type, data->ioc_inlbuf1, sizeof(__u32)); memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
if (type & LL_STATFS_LMV) if (type & LL_STATFS_LMV)
exp = sbi->ll_md_exp; exp = sbi->ll_md_exp;
else if (type & LL_STATFS_LOV) else if (type & LL_STATFS_LOV)
exp = sbi->ll_dt_exp; exp = sbi->ll_dt_exp;
else else {
GOTO(out_statfs, rc = -ENODEV); rc = -ENODEV;
goto out_statfs;
}
flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0; flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0;
rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags); rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags);
if (rc) if (rc)
GOTO(out_statfs, rc); goto out_statfs;
out_statfs: out_statfs:
if (buf) if (buf)
obd_ioctl_freedata(buf, len); obd_ioctl_freedata(buf, len);
......
...@@ -181,12 +181,14 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, ...@@ -181,12 +181,14 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
LASSERT(vmpage != NULL); LASSERT(vmpage != NULL);
io = ll_fault_io_init(vma, &env, &nest, vmpage->index, NULL); io = ll_fault_io_init(vma, &env, &nest, vmpage->index, NULL);
if (IS_ERR(io)) if (IS_ERR(io)) {
GOTO(out, result = PTR_ERR(io)); result = PTR_ERR(io);
goto out;
}
result = io->ci_result; result = io->ci_result;
if (result < 0) if (result < 0)
GOTO(out_io, result); goto out_io;
io->u.ci_fault.ft_mkwrite = 1; io->u.ci_fault.ft_mkwrite = 1;
io->u.ci_fault.ft_writable = 1; io->u.ci_fault.ft_writable = 1;
......
...@@ -236,11 +236,15 @@ static int ll_get_name(struct dentry *dentry, char *name, ...@@ -236,11 +236,15 @@ static int ll_get_name(struct dentry *dentry, char *name,
.ctx.actor = ll_nfs_get_name_filldir, .ctx.actor = ll_nfs_get_name_filldir,
}; };
if (!dir || !S_ISDIR(dir->i_mode)) if (!dir || !S_ISDIR(dir->i_mode)) {
GOTO(out, rc = -ENOTDIR); rc = -ENOTDIR;
goto out;
}
if (!dir->i_fop) if (!dir->i_fop) {
GOTO(out, rc = -EINVAL); rc = -EINVAL;
goto out;
}
mutex_lock(&dir->i_mutex); mutex_lock(&dir->i_mutex);
rc = ll_dir_read(dir, &lgd.ctx); rc = ll_dir_read(dir, &lgd.ctx);
......
...@@ -409,8 +409,10 @@ static int loop_thread(void *data) ...@@ -409,8 +409,10 @@ static int loop_thread(void *data)
lo->lo_state = LLOOP_BOUND; lo->lo_state = LLOOP_BOUND;
env = cl_env_get(&refcheck); env = cl_env_get(&refcheck);
if (IS_ERR(env)) if (IS_ERR(env)) {
GOTO(out, ret = PTR_ERR(env)); ret = PTR_ERR(env);
goto out;
}
lo->lo_env = env; lo->lo_env = env;
memset(&lo->lo_pvec, 0, sizeof(lo->lo_pvec)); memset(&lo->lo_pvec, 0, sizeof(lo->lo_pvec));
...@@ -670,8 +672,10 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, ...@@ -670,8 +672,10 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
if (magic != ll_iocontrol_magic) if (magic != ll_iocontrol_magic)
return LLIOC_CONT; return LLIOC_CONT;
if (disks == NULL) if (disks == NULL) {
GOTO(out1, err = -ENODEV); err = -ENODEV;
goto out1;
}
CWARN("Enter llop_ioctl\n"); CWARN("Enter llop_ioctl\n");
...@@ -692,19 +696,25 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, ...@@ -692,19 +696,25 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
file->f_dentry->d_inode) file->f_dentry->d_inode)
break; break;
} }
if (lo || !lo_free) if (lo || !lo_free) {
GOTO(out, err = -EBUSY); err = -EBUSY;
goto out;
}
lo = lo_free; lo = lo_free;
dev = MKDEV(lloop_major, lo->lo_number); dev = MKDEV(lloop_major, lo->lo_number);
/* quit if the used pointer is writable */ /* quit if the used pointer is writable */
if (put_user((long)old_encode_dev(dev), (long*)arg)) if (put_user((long)old_encode_dev(dev), (long*)arg)) {
GOTO(out, err = -EFAULT); err = -EFAULT;
goto out;
}
bdev = blkdev_get_by_dev(dev, file->f_mode, NULL); bdev = blkdev_get_by_dev(dev, file->f_mode, NULL);
if (IS_ERR(bdev)) if (IS_ERR(bdev)) {
GOTO(out, err = PTR_ERR(bdev)); err = PTR_ERR(bdev);
goto out;
}
get_file(file); get_file(file);
err = loop_set_fd(lo, NULL, bdev, file); err = loop_set_fd(lo, NULL, bdev, file);
...@@ -720,16 +730,22 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, ...@@ -720,16 +730,22 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
int minor; int minor;
dev = old_decode_dev(arg); dev = old_decode_dev(arg);
if (MAJOR(dev) != lloop_major) if (MAJOR(dev) != lloop_major) {
GOTO(out, err = -EINVAL); err = -EINVAL;
goto out;
}
minor = MINOR(dev); minor = MINOR(dev);
if (minor > max_loop - 1) if (minor > max_loop - 1) {
GOTO(out, err = -EINVAL); err = -EINVAL;
goto out;
}
lo = &loop_dev[minor]; lo = &loop_dev[minor];
if (lo->lo_state != LLOOP_BOUND) if (lo->lo_state != LLOOP_BOUND) {
GOTO(out, err = -EINVAL); err = -EINVAL;
goto out;
}
bdev = lo->lo_device; bdev = lo->lo_device;
err = loop_clr_fd(lo, bdev, 1); err = loop_clr_fd(lo, bdev, 1);
......
...@@ -410,7 +410,8 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, ...@@ -410,7 +410,8 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file,
/* easy - add more LRU slots. */ /* easy - add more LRU slots. */
if (diff >= 0) { if (diff >= 0) {
atomic_add(diff, &cache->ccc_lru_left); atomic_add(diff, &cache->ccc_lru_left);
GOTO(out, rc = 0); rc = 0;
goto out;
} }
diff = -diff; diff = -diff;
...@@ -997,8 +998,10 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, ...@@ -997,8 +998,10 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
/* File operations stats */ /* File operations stats */
sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES, sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
LPROCFS_STATS_FLAG_NONE); LPROCFS_STATS_FLAG_NONE);
if (sbi->ll_stats == NULL) if (sbi->ll_stats == NULL) {
GOTO(out, err = -ENOMEM); err = -ENOMEM;
goto out;
}
/* do counter init */ /* do counter init */
for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) { for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
__u32 type = llite_opcode_table[id].type; __u32 type = llite_opcode_table[id].type;
...@@ -1016,12 +1019,14 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, ...@@ -1016,12 +1019,14 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
} }
err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats); err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats);
if (err) if (err)
GOTO(out, err); goto out;
sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string), sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
LPROCFS_STATS_FLAG_NONE); LPROCFS_STATS_FLAG_NONE);
if (sbi->ll_ra_stats == NULL) if (sbi->ll_ra_stats == NULL) {
GOTO(out, err = -ENOMEM); err = -ENOMEM;
goto out;
}
for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++)
lprocfs_counter_init(sbi->ll_ra_stats, id, 0, lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
...@@ -1029,12 +1034,12 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, ...@@ -1029,12 +1034,12 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats", err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
sbi->ll_ra_stats); sbi->ll_ra_stats);
if (err) if (err)
GOTO(out, err); goto out;
err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb); err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb);
if (err) if (err)
GOTO(out, err); goto out;
/* MDC info */ /* MDC info */
obd = class_name2obd(mdc); obd = class_name2obd(mdc);
...@@ -1044,20 +1049,22 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, ...@@ -1044,20 +1049,22 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
LASSERT(obd->obd_type->typ_name != NULL); LASSERT(obd->obd_type->typ_name != NULL);
dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
if (dir == NULL) if (dir == NULL) {
GOTO(out, err = -ENOMEM); err = -ENOMEM;
goto out;
}
snprintf(name, MAX_STRING_SIZE, "common_name"); snprintf(name, MAX_STRING_SIZE, "common_name");
lvars[0].fops = &llite_name_fops; lvars[0].fops = &llite_name_fops;
err = lprocfs_add_vars(dir, lvars, obd); err = lprocfs_add_vars(dir, lvars, obd);
if (err) if (err)
GOTO(out, err); goto out;
snprintf(name, MAX_STRING_SIZE, "uuid"); snprintf(name, MAX_STRING_SIZE, "uuid");
lvars[0].fops = &llite_uuid_fops; lvars[0].fops = &llite_uuid_fops;
err = lprocfs_add_vars(dir, lvars, obd); err = lprocfs_add_vars(dir, lvars, obd);
if (err) if (err)
GOTO(out, err); goto out;
/* OSC */ /* OSC */
obd = class_name2obd(osc); obd = class_name2obd(osc);
...@@ -1067,14 +1074,16 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, ...@@ -1067,14 +1074,16 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
LASSERT(obd->obd_type->typ_name != NULL); LASSERT(obd->obd_type->typ_name != NULL);
dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root); dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
if (dir == NULL) if (dir == NULL) {
GOTO(out, err = -ENOMEM); err = -ENOMEM;
goto out;
}
snprintf(name, MAX_STRING_SIZE, "common_name"); snprintf(name, MAX_STRING_SIZE, "common_name");
lvars[0].fops = &llite_name_fops; lvars[0].fops = &llite_name_fops;
err = lprocfs_add_vars(dir, lvars, obd); err = lprocfs_add_vars(dir, lvars, obd);
if (err) if (err)
GOTO(out, err); goto out;
snprintf(name, MAX_STRING_SIZE, "uuid"); snprintf(name, MAX_STRING_SIZE, "uuid");
lvars[0].fops = &llite_uuid_fops; lvars[0].fops = &llite_uuid_fops;
......
...@@ -523,8 +523,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, ...@@ -523,8 +523,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
rc = ll_statahead_enter(parent, &dentry, 0); rc = ll_statahead_enter(parent, &dentry, 0);
if (rc == 1) { if (rc == 1) {
if (dentry == save) if (dentry == save)
GOTO(out, retval = NULL); retval = NULL;
GOTO(out, retval = dentry); else
retval = dentry;
goto out;
} }
} }
...@@ -546,13 +548,16 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, ...@@ -546,13 +548,16 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it, rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it,
lookup_flags, &req, ll_md_blocking_ast, 0); lookup_flags, &req, ll_md_blocking_ast, 0);
ll_finish_md_op_data(op_data); ll_finish_md_op_data(op_data);
if (rc < 0) if (rc < 0) {
GOTO(out, retval = ERR_PTR(rc)); retval = ERR_PTR(rc);
goto out;
}
rc = ll_lookup_it_finish(req, it, parent, &dentry); rc = ll_lookup_it_finish(req, it, parent, &dentry);
if (rc != 0) { if (rc != 0) {
ll_intent_release(it); ll_intent_release(it);
GOTO(out, retval = ERR_PTR(rc)); retval = ERR_PTR(rc);
goto out;
} }
if ((it->it_op & IT_OPEN) && dentry->d_inode && if ((it->it_op & IT_OPEN) && dentry->d_inode &&
...@@ -563,9 +568,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, ...@@ -563,9 +568,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
ll_lookup_finish_locks(it, dentry); ll_lookup_finish_locks(it, dentry);
if (dentry == save) if (dentry == save)
GOTO(out, retval = NULL); retval = NULL;
else else
GOTO(out, retval = dentry); retval = dentry;
goto out;
out: out:
if (req) if (req)
ptlrpc_req_finished(req); ptlrpc_req_finished(req);
...@@ -697,8 +703,10 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) ...@@ -697,8 +703,10 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
request = it->d.lustre.it_data; request = it->d.lustre.it_data;
it_clear_disposition(it, DISP_ENQ_CREATE_REF); it_clear_disposition(it, DISP_ENQ_CREATE_REF);
rc = ll_prep_inode(&inode, request, dir->i_sb, it); rc = ll_prep_inode(&inode, request, dir->i_sb, it);
if (rc) if (rc) {
GOTO(out, inode = ERR_PTR(rc)); inode = ERR_PTR(rc);
goto out;
}
LASSERT(ll_d_hlist_empty(&inode->i_dentry)); LASSERT(ll_d_hlist_empty(&inode->i_dentry));
...@@ -783,8 +791,10 @@ static int ll_new_node(struct inode *dir, struct qstr *name, ...@@ -783,8 +791,10 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name,
name->len, 0, opc, NULL); name->len, 0, opc, NULL);
if (IS_ERR(op_data)) if (IS_ERR(op_data)) {
GOTO(err_exit, err = PTR_ERR(op_data)); err = PTR_ERR(op_data);
goto err_exit;
}
err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode, err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
from_kuid(&init_user_ns, current_fsuid()), from_kuid(&init_user_ns, current_fsuid()),
...@@ -792,14 +802,14 @@ static int ll_new_node(struct inode *dir, struct qstr *name, ...@@ -792,14 +802,14 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
cfs_curproc_cap_pack(), rdev, &request); cfs_curproc_cap_pack(), rdev, &request);
ll_finish_md_op_data(op_data); ll_finish_md_op_data(op_data);
if (err) if (err)
GOTO(err_exit, err); goto err_exit;
ll_update_times(request, dir); ll_update_times(request, dir);
if (dchild) { if (dchild) {
err = ll_prep_inode(&inode, request, dchild->d_sb, NULL); err = ll_prep_inode(&inode, request, dchild->d_sb, NULL);
if (err) if (err)
GOTO(err_exit, err); goto err_exit;
d_instantiate(dchild, inode); d_instantiate(dchild, inode);
} }
...@@ -907,7 +917,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, ...@@ -907,7 +917,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir,
err = md_link(sbi->ll_md_exp, op_data, &request); err = md_link(sbi->ll_md_exp, op_data, &request);
ll_finish_md_op_data(op_data); ll_finish_md_op_data(op_data);
if (err) if (err)
GOTO(out, err); goto out;
ll_update_times(request, dir); ll_update_times(request, dir);
ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1);
...@@ -1028,7 +1038,8 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) ...@@ -1028,7 +1038,8 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
if (body->eadatasize == 0) { if (body->eadatasize == 0) {
CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n");
GOTO(out, rc = -EPROTO); rc = -EPROTO;
goto out;
} }
/* The MDS sent back the EA because we unlinked the last reference /* The MDS sent back the EA because we unlinked the last reference
...@@ -1042,13 +1053,15 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) ...@@ -1042,13 +1053,15 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
rc = obd_unpackmd(ll_i2dtexp(dir), &lsm, eadata, body->eadatasize); rc = obd_unpackmd(ll_i2dtexp(dir), &lsm, eadata, body->eadatasize);
if (rc < 0) { if (rc < 0) {
CERROR("obd_unpackmd: %d\n", rc); CERROR("obd_unpackmd: %d\n", rc);
GOTO(out, rc); goto out;
} }
LASSERT(rc >= sizeof(*lsm)); LASSERT(rc >= sizeof(*lsm));
OBDO_ALLOC(oa); OBDO_ALLOC(oa);
if (oa == NULL) if (oa == NULL) {
GOTO(out_free_memmd, rc = -ENOMEM); rc = -ENOMEM;
goto out_free_memmd;
}
oa->o_oi = lsm->lsm_oi; oa->o_oi = lsm->lsm_oi;
oa->o_mode = body->mode & S_IFMT; oa->o_mode = body->mode & S_IFMT;
...@@ -1070,7 +1083,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) ...@@ -1070,7 +1083,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
if (body->valid & OBD_MD_FLOSSCAPA) { if (body->valid & OBD_MD_FLOSSCAPA) {
rc = md_unpack_capa(ll_i2mdexp(dir), request, &RMF_CAPA2, &oc); rc = md_unpack_capa(ll_i2mdexp(dir), request, &RMF_CAPA2, &oc);
if (rc) if (rc)
GOTO(out_free_memmd, rc); goto out_free_memmd;
} }
rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti, rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti,
...@@ -1116,7 +1129,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, ...@@ -1116,7 +1129,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent,
rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
ll_finish_md_op_data(op_data); ll_finish_md_op_data(op_data);
if (rc) if (rc)
GOTO(out, rc); goto out;
ll_update_times(request, dir); ll_update_times(request, dir);
ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1); ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1);
......
...@@ -144,8 +144,10 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) ...@@ -144,8 +144,10 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask)
break; break;
} }
if (!found) if (!found) {
GOTO(out, rc = -ENOENT); rc = -ENOENT;
goto out;
}
CDEBUG(D_SEC, "found remote perm: %u/%u/%u/%u - %#x\n", CDEBUG(D_SEC, "found remote perm: %u/%u/%u/%u - %#x\n",
lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid,
......
...@@ -317,8 +317,10 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, ...@@ -317,8 +317,10 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi,
* otherwise it will form small read RPC(< 1M), which hurt server * otherwise it will form small read RPC(< 1M), which hurt server
* performance a lot. */ * performance a lot. */
ret = min(ra->ra_max_pages - atomic_read(&ra->ra_cur_pages), pages); ret = min(ra->ra_max_pages - atomic_read(&ra->ra_cur_pages), pages);
if (ret < 0 || ret < min_t(long, PTLRPC_MAX_BRW_PAGES, pages)) if (ret < 0 || ret < min_t(long, PTLRPC_MAX_BRW_PAGES, pages)) {
GOTO(out, ret = 0); ret = 0;
goto out;
}
/* If the non-strided (ria_pages == 0) readahead window /* If the non-strided (ria_pages == 0) readahead window
* (ria_start + ret) has grown across an RPC boundary, then trim * (ria_start + ret) has grown across an RPC boundary, then trim
...@@ -1018,7 +1020,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, ...@@ -1018,7 +1020,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
ras->ras_next_readahead = 0; ras->ras_next_readahead = 0;
ras->ras_window_len = min(ra->ra_max_pages_per_file, ras->ras_window_len = min(ra->ra_max_pages_per_file,
ra->ra_max_read_ahead_whole_pages); ra->ra_max_read_ahead_whole_pages);
GOTO(out_unlock, 0); goto out_unlock;
} }
} }
if (zero) { if (zero) {
...@@ -1033,7 +1035,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, ...@@ -1033,7 +1035,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
} }
ras_reset(inode, ras, index); ras_reset(inode, ras, index);
ras->ras_consecutive_pages++; ras->ras_consecutive_pages++;
GOTO(out_unlock, 0); goto out_unlock;
} else { } else {
ras->ras_consecutive_pages = 0; ras->ras_consecutive_pages = 0;
ras->ras_consecutive_requests = 0; ras->ras_consecutive_requests = 0;
...@@ -1058,7 +1060,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, ...@@ -1058,7 +1060,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
ras_reset(inode, ras, index); ras_reset(inode, ras, index);
ras->ras_consecutive_pages++; ras->ras_consecutive_pages++;
ras_stride_reset(ras); ras_stride_reset(ras);
GOTO(out_unlock, 0); goto out_unlock;
} }
} else if (stride_io_mode(ras)) { } else if (stride_io_mode(ras)) {
/* If this is contiguous read but in stride I/O mode /* If this is contiguous read but in stride I/O mode
...@@ -1090,7 +1092,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, ...@@ -1090,7 +1092,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
* is not incremented and thus can't be used to trigger RA */ * is not incremented and thus can't be used to trigger RA */
if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) { if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) {
ras->ras_window_len = RAS_INCREASE_STEP(inode); ras->ras_window_len = RAS_INCREASE_STEP(inode);
GOTO(out_unlock, 0); goto out_unlock;
} }
/* Initially reset the stride window offset to next_readahead*/ /* Initially reset the stride window offset to next_readahead*/
...@@ -1136,8 +1138,10 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) ...@@ -1136,8 +1138,10 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
LASSERT(ll_i2dtexp(inode) != NULL); LASSERT(ll_i2dtexp(inode) != NULL);
env = cl_env_nested_get(&nest); env = cl_env_nested_get(&nest);
if (IS_ERR(env)) if (IS_ERR(env)) {
GOTO(out, result = PTR_ERR(env)); result = PTR_ERR(env);
goto out;
}
clob = ll_i2info(inode)->lli_clob; clob = ll_i2info(inode)->lli_clob;
LASSERT(clob != NULL); LASSERT(clob != NULL);
...@@ -1197,7 +1201,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) ...@@ -1197,7 +1201,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
} }
cl_env_nested_put(&nest, env); cl_env_nested_put(&nest, env);
GOTO(out, result); goto out;
out: out:
if (result < 0) { if (result < 0) {
......
...@@ -441,7 +441,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, ...@@ -441,7 +441,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
continue; continue;
} }
GOTO(out, result); goto out;
} }
iov_iter_advance(iter, result); iov_iter_advance(iter, result);
tot_bytes += result; tot_bytes += result;
......
...@@ -637,8 +637,10 @@ static void ll_post_statahead(struct ll_statahead_info *sai) ...@@ -637,8 +637,10 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
it = &minfo->mi_it; it = &minfo->mi_it;
req = entry->se_req; req = entry->se_req;
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL) if (body == NULL) {
GOTO(out, rc = -EFAULT); rc = -EFAULT;
goto out;
}
child = entry->se_inode; child = entry->se_inode;
if (child == NULL) { if (child == NULL) {
...@@ -649,8 +651,10 @@ static void ll_post_statahead(struct ll_statahead_info *sai) ...@@ -649,8 +651,10 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
/* XXX: No fid in reply, this is probably cross-ref case. /* XXX: No fid in reply, this is probably cross-ref case.
* SA can't handle it yet. */ * SA can't handle it yet. */
if (body->valid & OBD_MD_MDS) if (body->valid & OBD_MD_MDS) {
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
}
} else { } else {
/* /*
* revalidate. * revalidate.
...@@ -665,12 +669,14 @@ static void ll_post_statahead(struct ll_statahead_info *sai) ...@@ -665,12 +669,14 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
it->d.lustre.it_lock_handle = entry->se_handle; it->d.lustre.it_lock_handle = entry->se_handle;
rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL); rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL);
if (rc != 1) if (rc != 1) {
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
}
rc = ll_prep_inode(&child, req, dir->i_sb, it); rc = ll_prep_inode(&child, req, dir->i_sb, it);
if (rc) if (rc)
GOTO(out, rc); goto out;
CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
child, child->i_ino, child->i_generation); child, child->i_ino, child->i_generation);
...@@ -711,20 +717,23 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, ...@@ -711,20 +717,23 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
if (unlikely(lli->lli_sai == NULL || if (unlikely(lli->lli_sai == NULL ||
lli->lli_sai->sai_generation != minfo->mi_generation)) { lli->lli_sai->sai_generation != minfo->mi_generation)) {
spin_unlock(&lli->lli_sa_lock); spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -ESTALE); rc = -ESTALE;
goto out;
} else { } else {
sai = ll_sai_get(lli->lli_sai); sai = ll_sai_get(lli->lli_sai);
if (unlikely(!thread_is_running(&sai->sai_thread))) { if (unlikely(!thread_is_running(&sai->sai_thread))) {
sai->sai_replied++; sai->sai_replied++;
spin_unlock(&lli->lli_sa_lock); spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -EBADFD); rc = -EBADFD;
goto out;
} }
entry = ll_sa_entry_get_byindex(sai, minfo->mi_cbdata); entry = ll_sa_entry_get_byindex(sai, minfo->mi_cbdata);
if (entry == NULL) { if (entry == NULL) {
sai->sai_replied++; sai->sai_replied++;
spin_unlock(&lli->lli_sa_lock); spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -EIDRM); rc = -EIDRM;
goto out;
} }
if (rc != 0) { if (rc != 0) {
...@@ -1085,7 +1094,7 @@ static int ll_statahead_thread(void *arg) ...@@ -1085,7 +1094,7 @@ static int ll_statahead_thread(void *arg)
CDEBUG(D_READA, "error reading dir "DFID" at %llu/%llu: [rc %d] [parent %u]\n", CDEBUG(D_READA, "error reading dir "DFID" at %llu/%llu: [rc %d] [parent %u]\n",
PFID(ll_inode2fid(dir)), pos, sai->sai_index, PFID(ll_inode2fid(dir)), pos, sai->sai_index,
rc, plli->lli_opendir_pid); rc, plli->lli_opendir_pid);
GOTO(out, rc); goto out;
} }
dp = page_address(page); dp = page_address(page);
...@@ -1150,7 +1159,8 @@ static int ll_statahead_thread(void *arg) ...@@ -1150,7 +1159,8 @@ static int ll_statahead_thread(void *arg)
if (unlikely(!thread_is_running(thread))) { if (unlikely(!thread_is_running(thread))) {
ll_release_page(page, 0); ll_release_page(page, 0);
GOTO(out, rc = 0); rc = 0;
goto out;
} }
/* If no window for metadata statahead, but there are /* If no window for metadata statahead, but there are
...@@ -1171,7 +1181,8 @@ static int ll_statahead_thread(void *arg) ...@@ -1171,7 +1181,8 @@ static int ll_statahead_thread(void *arg)
if (unlikely( if (unlikely(
!thread_is_running(thread))) { !thread_is_running(thread))) {
ll_release_page(page, 0); ll_release_page(page, 0);
GOTO(out, rc = 0); rc = 0;
goto out;
} }
if (!sa_sent_full(sai)) if (!sa_sent_full(sai))
...@@ -1203,8 +1214,10 @@ static int ll_statahead_thread(void *arg) ...@@ -1203,8 +1214,10 @@ static int ll_statahead_thread(void *arg)
while (!sa_received_empty(sai)) while (!sa_received_empty(sai))
ll_post_statahead(sai); ll_post_statahead(sai);
if (unlikely(!thread_is_running(thread))) if (unlikely(!thread_is_running(thread))) {
GOTO(out, rc = 0); rc = 0;
goto out;
}
if (sai->sai_sent == sai->sai_replied && if (sai->sai_sent == sai->sai_replied &&
sa_received_empty(sai)) sa_received_empty(sai))
...@@ -1222,7 +1235,8 @@ static int ll_statahead_thread(void *arg) ...@@ -1222,7 +1235,8 @@ static int ll_statahead_thread(void *arg)
} }
spin_unlock(&plli->lli_agl_lock); spin_unlock(&plli->lli_agl_lock);
GOTO(out, rc = 0); rc = 0;
goto out;
} else if (1) { } else if (1) {
/* /*
* chain is exhausted. * chain is exhausted.
...@@ -1422,7 +1436,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) ...@@ -1422,7 +1436,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
rc = LS_FIRST_DOT_DE; rc = LS_FIRST_DOT_DE;
ll_release_page(page, 0); ll_release_page(page, 0);
GOTO(out, rc); goto out;
} }
pos = le64_to_cpu(dp->ldp_hash_end); pos = le64_to_cpu(dp->ldp_hash_end);
if (pos == MDS_DIR_END_OFF) { if (pos == MDS_DIR_END_OFF) {
...@@ -1626,20 +1640,25 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, ...@@ -1626,20 +1640,25 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
/* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */ /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */
rc = is_first_dirent(dir, *dentryp); rc = is_first_dirent(dir, *dentryp);
if (rc == LS_NONE_FIRST_DE) if (rc == LS_NONE_FIRST_DE) {
/* It is not "ls -{a}l" operation, no need statahead for it. */ /* It is not "ls -{a}l" operation, no need statahead for it. */
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
}
sai = ll_sai_alloc(); sai = ll_sai_alloc();
if (sai == NULL) if (sai == NULL) {
GOTO(out, rc = -ENOMEM); rc = -ENOMEM;
goto out;
}
sai->sai_ls_all = (rc == LS_FIRST_DOT_DE); sai->sai_ls_all = (rc == LS_FIRST_DOT_DE);
sai->sai_inode = igrab(dir); sai->sai_inode = igrab(dir);
if (unlikely(sai->sai_inode == NULL)) { if (unlikely(sai->sai_inode == NULL)) {
CWARN("Do not start stat ahead on dying inode "DFID"\n", CWARN("Do not start stat ahead on dying inode "DFID"\n",
PFID(&lli->lli_fid)); PFID(&lli->lli_fid));
GOTO(out, rc = -ESTALE); rc = -ESTALE;
goto out;
} }
/* get parent reference count here, and put it in ll_statahead_thread */ /* get parent reference count here, and put it in ll_statahead_thread */
...@@ -1653,7 +1672,8 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, ...@@ -1653,7 +1672,8 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
PFID(&lli->lli_fid), PFID(&nlli->lli_fid)); PFID(&lli->lli_fid), PFID(&nlli->lli_fid));
dput(parent); dput(parent);
iput(sai->sai_inode); iput(sai->sai_inode);
GOTO(out, rc = -EAGAIN); rc = -EAGAIN;
goto out;
} }
CDEBUG(D_READA, "start statahead thread: sai %p, parent %.*s\n", CDEBUG(D_READA, "start statahead thread: sai %p, parent %.*s\n",
......
...@@ -77,21 +77,23 @@ static int ll_readlink_internal(struct inode *inode, ...@@ -77,21 +77,23 @@ static int ll_readlink_internal(struct inode *inode,
if (rc) { if (rc) {
if (rc != -ENOENT) if (rc != -ENOENT)
CERROR("inode %lu: rc = %d\n", inode->i_ino, rc); CERROR("inode %lu: rc = %d\n", inode->i_ino, rc);
GOTO (failed, rc); goto failed;
} }
body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY);
LASSERT(body != NULL); LASSERT(body != NULL);
if ((body->valid & OBD_MD_LINKNAME) == 0) { if ((body->valid & OBD_MD_LINKNAME) == 0) {
CERROR("OBD_MD_LINKNAME not set on reply\n"); CERROR("OBD_MD_LINKNAME not set on reply\n");
GOTO(failed, rc = -EPROTO); rc = -EPROTO;
goto failed;
} }
LASSERT(symlen != 0); LASSERT(symlen != 0);
if (body->eadatasize != symlen) { if (body->eadatasize != symlen) {
CERROR("inode %lu: symlink length %d not expected %d\n", CERROR("inode %lu: symlink length %d not expected %d\n",
inode->i_ino, body->eadatasize - 1, symlen - 1); inode->i_ino, body->eadatasize - 1, symlen - 1);
GOTO(failed, rc = -EPROTO); rc = -EPROTO;
goto failed;
} }
*symname = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_MD); *symname = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_MD);
...@@ -100,7 +102,8 @@ static int ll_readlink_internal(struct inode *inode, ...@@ -100,7 +102,8 @@ static int ll_readlink_internal(struct inode *inode,
/* not full/NULL terminated */ /* not full/NULL terminated */
CERROR("inode %lu: symlink not NULL terminated string" CERROR("inode %lu: symlink not NULL terminated string"
"of length %d\n", inode->i_ino, symlen - 1); "of length %d\n", inode->i_ino, symlen - 1);
GOTO(failed, rc = -EPROTO); rc = -EPROTO;
goto failed;
} }
OBD_ALLOC(lli->lli_symlink_name, symlen); OBD_ALLOC(lli->lli_symlink_name, symlen);
......
...@@ -704,7 +704,8 @@ static int vvp_io_fault_start(const struct lu_env *env, ...@@ -704,7 +704,8 @@ static int vvp_io_fault_start(const struct lu_env *env,
/* return +1 to stop cl_io_loop() and ll_fault() will catch /* return +1 to stop cl_io_loop() and ll_fault() will catch
* and retry. */ * and retry. */
GOTO(out, result = +1); result = +1;
goto out;
} }
...@@ -733,13 +734,16 @@ static int vvp_io_fault_start(const struct lu_env *env, ...@@ -733,13 +734,16 @@ static int vvp_io_fault_start(const struct lu_env *env,
* in ll_page_mkwrite0. Thus we return -ENODATA * in ll_page_mkwrite0. Thus we return -ENODATA
* to handle both cases * to handle both cases
*/ */
GOTO(out, result = -ENODATA); result = -ENODATA;
goto out;
} }
} }
page = cl_page_find(env, obj, fio->ft_index, vmpage, CPT_CACHEABLE); page = cl_page_find(env, obj, fio->ft_index, vmpage, CPT_CACHEABLE);
if (IS_ERR(page)) if (IS_ERR(page)) {
GOTO(out, result = PTR_ERR(page)); result = PTR_ERR(page);
goto out;
}
/* if page is going to be written, we should add this page into cache /* if page is going to be written, we should add this page into cache
* earlier. */ * earlier. */
...@@ -771,7 +775,7 @@ static int vvp_io_fault_start(const struct lu_env *env, ...@@ -771,7 +775,7 @@ static int vvp_io_fault_start(const struct lu_env *env,
/* we're in big trouble, what can we do now? */ /* we're in big trouble, what can we do now? */
if (result == -EDQUOT) if (result == -EDQUOT)
result = -ENOSPC; result = -ENOSPC;
GOTO(out, result); goto out;
} else } else
cl_page_disown(env, io, page); cl_page_disown(env, io, page);
} }
......
...@@ -364,7 +364,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, ...@@ -364,7 +364,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
if (rc == -EAGAIN) if (rc == -EAGAIN)
goto getxattr_nocache; goto getxattr_nocache;
if (rc < 0) if (rc < 0)
GOTO(out_xattr, rc); goto out_xattr;
/* Add "system.posix_acl_access" to the list */ /* Add "system.posix_acl_access" to the list */
if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) { if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
...@@ -375,7 +375,8 @@ int ll_getxattr_common(struct inode *inode, const char *name, ...@@ -375,7 +375,8 @@ int ll_getxattr_common(struct inode *inode, const char *name,
sizeof(XATTR_NAME_ACL_ACCESS)); sizeof(XATTR_NAME_ACL_ACCESS));
rc += sizeof(XATTR_NAME_ACL_ACCESS); rc += sizeof(XATTR_NAME_ACL_ACCESS);
} else { } else {
GOTO(out_xattr, rc = -ERANGE); rc = -ERANGE;
goto out_xattr;
} }
} }
} else { } else {
...@@ -387,29 +388,36 @@ int ll_getxattr_common(struct inode *inode, const char *name, ...@@ -387,29 +388,36 @@ int ll_getxattr_common(struct inode *inode, const char *name,
capa_put(oc); capa_put(oc);
if (rc < 0) if (rc < 0)
GOTO(out_xattr, rc); goto out_xattr;
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
LASSERT(body); LASSERT(body);
/* only detect the xattr size */ /* only detect the xattr size */
if (size == 0) if (size == 0) {
GOTO(out, rc = body->eadatasize); rc = body->eadatasize;
goto out;
}
if (size < body->eadatasize) { if (size < body->eadatasize) {
CERROR("server bug: replied size %u > %u\n", CERROR("server bug: replied size %u > %u\n",
body->eadatasize, (int)size); body->eadatasize, (int)size);
GOTO(out, rc = -ERANGE); rc = -ERANGE;
goto out;
} }
if (body->eadatasize == 0) if (body->eadatasize == 0) {
GOTO(out, rc = -ENODATA); rc = -ENODATA;
goto out;
}
/* do not need swab xattr data */ /* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
body->eadatasize); body->eadatasize);
if (!xdata) if (!xdata) {
GOTO(out, rc = -EFAULT); rc = -EFAULT;
goto out;
}
memcpy(buffer, xdata, body->eadatasize); memcpy(buffer, xdata, body->eadatasize);
rc = body->eadatasize; rc = body->eadatasize;
...@@ -421,14 +429,16 @@ int ll_getxattr_common(struct inode *inode, const char *name, ...@@ -421,14 +429,16 @@ int ll_getxattr_common(struct inode *inode, const char *name,
acl = lustre_posix_acl_xattr_2ext( acl = lustre_posix_acl_xattr_2ext(
(posix_acl_xattr_header *)buffer, rc); (posix_acl_xattr_header *)buffer, rc);
if (IS_ERR(acl)) if (IS_ERR(acl)) {
GOTO(out, rc = PTR_ERR(acl)); rc = PTR_ERR(acl);
goto out;
}
rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode), rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
xattr_type, acl); xattr_type, acl);
if (unlikely(rc < 0)) { if (unlikely(rc < 0)) {
lustre_ext_acl_xattr_free(acl); lustre_ext_acl_xattr_free(acl);
GOTO(out, rc); goto out;
} }
} }
#endif #endif
...@@ -476,7 +486,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, ...@@ -476,7 +486,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
if (size == 0 && S_ISDIR(inode->i_mode)) { if (size == 0 && S_ISDIR(inode->i_mode)) {
/* XXX directory EA is fix for now, optimize to save /* XXX directory EA is fix for now, optimize to save
* RPC transfer */ * RPC transfer */
GOTO(out, rc = sizeof(struct lov_user_md)); rc = sizeof(struct lov_user_md);
goto out;
} }
lsm = ccc_inode_lsm_get(inode); lsm = ccc_inode_lsm_get(inode);
...@@ -496,7 +507,7 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, ...@@ -496,7 +507,7 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
ccc_inode_lsm_put(inode, lsm); ccc_inode_lsm_put(inode, lsm);
if (rc < 0) if (rc < 0)
GOTO(out, rc); goto out;
if (size == 0) { if (size == 0) {
/* used to call ll_get_max_mdsize() forward to get /* used to call ll_get_max_mdsize() forward to get
...@@ -504,13 +515,14 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name, ...@@ -504,13 +515,14 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
* rsync 3.0.x) care much about the exact xattr value * rsync 3.0.x) care much about the exact xattr value
* size */ * size */
rc = lmmsize; rc = lmmsize;
GOTO(out, rc); goto out;
} }
if (size < lmmsize) { if (size < lmmsize) {
CERROR("server bug: replied size %d > %d for %s (%s)\n", CERROR("server bug: replied size %d > %d for %s (%s)\n",
lmmsize, (int)size, dentry->d_name.name, name); lmmsize, (int)size, dentry->d_name.name, name);
GOTO(out, rc = -ERANGE); rc = -ERANGE;
goto out;
} }
lump = (struct lov_user_md *)buffer; lump = (struct lov_user_md *)buffer;
...@@ -549,7 +561,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) ...@@ -549,7 +561,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS); rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);
if (rc < 0) if (rc < 0)
GOTO(out, rc); goto out;
if (buffer != NULL) { if (buffer != NULL) {
struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_sb_info *sbi = ll_i2sbi(inode);
...@@ -582,7 +594,8 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) ...@@ -582,7 +594,8 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
} }
if (rc2 < 0) { if (rc2 < 0) {
GOTO(out, rc2 = 0); rc2 = 0;
goto out;
} else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) { } else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) {
const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1; const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1;
const size_t name_len = sizeof("lov") - 1; const size_t name_len = sizeof("lov") - 1;
......
...@@ -365,18 +365,20 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) ...@@ -365,18 +365,20 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
rc = ll_xattr_find_get_lock(inode, oit, &req); rc = ll_xattr_find_get_lock(inode, oit, &req);
if (rc) if (rc)
GOTO(out_no_unlock, rc); goto out_no_unlock;
/* Do we have the data at this point? */ /* Do we have the data at this point? */
if (ll_xattr_cache_valid(lli)) { if (ll_xattr_cache_valid(lli)) {
ll_stats_ops_tally(sbi, LPROC_LL_GETXATTR_HITS, 1); ll_stats_ops_tally(sbi, LPROC_LL_GETXATTR_HITS, 1);
GOTO(out_maybe_drop, rc = 0); rc = 0;
goto out_maybe_drop;
} }
/* Matched but no cache? Cancelled on error by a parallel refill. */ /* Matched but no cache? Cancelled on error by a parallel refill. */
if (unlikely(req == NULL)) { if (unlikely(req == NULL)) {
CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n"); CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n");
GOTO(out_maybe_drop, rc = -EIO); rc = -EIO;
goto out_maybe_drop;
} }
if (oit->d.lustre.it_status < 0) { if (oit->d.lustre.it_status < 0) {
...@@ -386,13 +388,14 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) ...@@ -386,13 +388,14 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
/* xattr data is so large that we don't want to cache it */ /* xattr data is so large that we don't want to cache it */
if (rc == -ERANGE) if (rc == -ERANGE)
rc = -EAGAIN; rc = -EAGAIN;
GOTO(out_destroy, rc); goto out_destroy;
} }
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL) { if (body == NULL) {
CERROR("no MDT BODY in the refill xattr reply\n"); CERROR("no MDT BODY in the refill xattr reply\n");
GOTO(out_destroy, rc = -EPROTO); rc = -EPROTO;
goto out_destroy;
} }
/* do not need swab xattr data */ /* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
...@@ -403,7 +406,8 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) ...@@ -403,7 +406,8 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
body->max_mdsize * sizeof(__u32)); body->max_mdsize * sizeof(__u32));
if (xdata == NULL || xval == NULL || xsizes == NULL) { if (xdata == NULL || xval == NULL || xsizes == NULL) {
CERROR("wrong setxattr reply\n"); CERROR("wrong setxattr reply\n");
GOTO(out_destroy, rc = -EPROTO); rc = -EPROTO;
goto out_destroy;
} }
xtail = xdata + body->eadatasize; xtail = xdata + body->eadatasize;
...@@ -435,7 +439,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) ...@@ -435,7 +439,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
} }
if (rc < 0) { if (rc < 0) {
ll_xattr_cache_destroy_locked(lli); ll_xattr_cache_destroy_locked(lli);
GOTO(out_destroy, rc); goto out_destroy;
} }
xdata += strlen(xdata) + 1; xdata += strlen(xdata) + 1;
xval += *xsizes; xval += *xsizes;
...@@ -447,7 +451,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) ...@@ -447,7 +451,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
ll_set_lock_data(sbi->ll_md_exp, inode, oit, NULL); ll_set_lock_data(sbi->ll_md_exp, inode, oit, NULL);
GOTO(out_maybe_drop, rc); goto out_maybe_drop;
out_maybe_drop: out_maybe_drop:
ll_intent_drop_lock(oit); ll_intent_drop_lock(oit);
...@@ -528,7 +532,7 @@ int ll_xattr_cache_get(struct inode *inode, ...@@ -528,7 +532,7 @@ int ll_xattr_cache_get(struct inode *inode,
size ? buffer : NULL, size); size ? buffer : NULL, size);
} }
GOTO(out, rc); goto out;
out: out:
up_read(&lli->lli_xattrs_list_rwsem); up_read(&lli->lli_xattrs_list_rwsem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment