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)
"renewal failed: -EIO, "
"retry in 2 mins");
ll_capa_renewal_retries++;
GOTO(retry, rc);
goto retry;
} else {
DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
"renewal failed(rc: %d) for", rc);
......
......@@ -155,7 +155,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
inode = igrab(inode);
LASSERT(inode);
GOTO(out, 0);
goto out;
}
if (flags & LLIF_DONE_WRITING) {
/* 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,
inode = igrab(inode);
LASSERT(inode);
GOTO(out, 0);
goto out;
}
}
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,
/* Pack Size-on-MDS inode attributes only if they has changed */
if (!(lli->lli_flags & LLIF_SOM_DIRTY)) {
spin_unlock(&lli->lli_lock);
GOTO(out, 0);
goto out;
}
/* There is a pending DONE_WRITE -- close epoch with no
* attribute change. */
if (lli->lli_flags & LLIF_EPOCH_PENDING) {
spin_unlock(&lli->lli_lock);
GOTO(out, 0);
goto out;
}
}
......@@ -294,7 +294,7 @@ static void ll_done_writing(struct inode *inode)
ll_prepare_done_writing(inode, op_data, &och);
/* If there is no @och, we do not do D_W yet. */
if (och == NULL)
GOTO(out, 0);
goto out;
rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL);
if (rc == -EAGAIN) {
......
......@@ -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 "
"part. Please wait for recovery to complete,"
" abort, or time out.\n", md);
GOTO(out, err);
goto out;
} else if (err) {
CERROR("cannot connect to %s: rc = %d\n", md, err);
GOTO(out, err);
goto out;
}
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,
if (err) {
CERROR("%s: Can't init metadata layer FID infrastructure, "
"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
......@@ -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),
OBD_STATFS_FOR_MDT0);
if (err)
GOTO(out_md_fid, err);
goto out_md_fid;
/* This needs to be after statfs to ensure connect has finished.
* 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,
"server or downgrade client.\n",
sbi->ll_md_exp->exp_obd->obd_name, buf);
OBD_FREE(buf, PAGE_CACHE_SIZE);
GOTO(out_md_fid, err = -EPROTO);
err = -EPROTO;
goto out_md_fid;
}
size = sizeof(*data);
......@@ -311,7 +312,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: Get connect data failed: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err);
GOTO(out_md_fid, err);
goto out_md_fid;
}
LASSERT(osfs->os_bsize);
......@@ -392,7 +393,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
obd = class_name2obd(dt);
if (!obd) {
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 |
......@@ -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 "
"part. Please wait for recovery to "
"complete, abort, or time out.\n", dt);
GOTO(out_md, err);
goto out_md;
} else if (err) {
CERROR("%s: Cannot connect to %s: rc = %d\n",
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;
......@@ -457,7 +459,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: Can't init data layer FID infrastructure, "
"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);
......@@ -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);
if (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)) {
CERROR("%s: Invalid root fid "DFID" during mount\n",
sbi->ll_md_exp->exp_obd->obd_name,
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));
......@@ -494,8 +497,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
valid |= OBD_MD_FLACL;
OBD_ALLOC_PTR(op_data);
if (op_data == NULL)
GOTO(out_lock_cn_cb, err = -ENOMEM);
if (op_data == NULL) {
err = -ENOMEM;
goto out_lock_cn_cb;
}
op_data->op_fid1 = sbi->ll_root_fid;
op_data->op_mode = 0;
......@@ -509,7 +514,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: md_getattr failed for root: rc = %d\n",
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,
......@@ -517,7 +522,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("failed to understand root inode md: rc = %d\n", err);
ptlrpc_req_finished(request);
GOTO(out_lock_cn_cb, err);
goto out_lock_cn_cb;
}
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,
err = IS_ERR(root) ? PTR_ERR(root) : -EBADF;
root = NULL;
CERROR("lustre_lite: bad iget4 for root\n");
GOTO(out_root, err);
goto out_root;
}
err = ll_close_thread_start(&sbi->ll_lcq);
if (err) {
CERROR("cannot start close thread: rc %d\n", err);
GOTO(out_root, err);
goto out_root;
}
#ifdef CONFIG_FS_POSIX_ACL
......@@ -569,7 +574,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (sb->s_root == NULL) {
CERROR("%s: can't make root dentry\n",
ll_get_fsname(sb, NULL, 0));
GOTO(out_root, err = -ENOMEM);
err = -ENOMEM;
goto out_root;
}
sbi->ll_sdev_orig = sb->s_dev;
......@@ -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);
if (err)
GOTO(out_free, err);
goto out_free;
err = bdi_init(&lsi->lsi_bdi);
if (err)
GOTO(out_free, err);
goto out_free;
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);
goto out_free;
sb->s_bdi = &lsi->lsi_bdi;
/* 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)
err = lustre_process_log(sb, profilenm, cfg);
if (err < 0) {
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 */
......@@ -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"
" read from the MGS. Does that filesystem "
"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,
lprof->lp_md, lprof->lp_dt);
OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2);
if (!dt)
GOTO(out_free, err = -ENOMEM);
if (!dt) {
err = -ENOMEM;
goto out_free;
}
sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2);
if (!md)
GOTO(out_free, err = -ENOMEM);
if (!md) {
err = -ENOMEM;
goto out_free;
}
sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
/* connections, registrations, sb setup */
......@@ -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);
if (rc)
GOTO(out, rc);
goto out;
/* truncate failed (only when non HSM import), others succeed */
if (file_is_released) {
if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
GOTO(out, rc = -ENODATA);
rc = -ENODATA;
else
GOTO(out, rc = 0);
rc = 0;
goto out;
}
/* 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)
}
ll_ioepoch_open(lli, op_data->op_ioepoch);
if (!S_ISREG(inode->i_mode))
GOTO(out, rc = 0);
if (!S_ISREG(inode->i_mode)) {
rc = 0;
goto out;
}
if (attr->ia_valid & (ATTR_SIZE |
ATTR_ATIME | ATTR_ATIME_SET |
......@@ -2103,7 +2117,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
rc = IS_ERR(*inode) ? PTR_ERR(*inode) : -ENOMEM;
*inode = NULL;
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)
__u32 flags;
int len = 0, rc;
if (!inode || !(sbi = ll_i2sbi(inode)))
GOTO(out_statfs, rc = -EINVAL);
if (!inode || !(sbi = ll_i2sbi(inode))) {
rc = -EINVAL;
goto out_statfs;
}
rc = obd_ioctl_getdata(&buf, &len, arg);
if (rc)
GOTO(out_statfs, rc);
goto out_statfs;
data = (void*)buf;
if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
!data->ioc_pbuf1 || !data->ioc_pbuf2)
GOTO(out_statfs, rc = -EINVAL);
!data->ioc_pbuf1 || !data->ioc_pbuf2) {
rc = -EINVAL;
goto out_statfs;
}
if (data->ioc_inllen1 != sizeof(__u32) ||
data->ioc_inllen2 != sizeof(__u32) ||
data->ioc_plen1 != sizeof(struct obd_statfs) ||
data->ioc_plen2 != sizeof(struct obd_uuid))
GOTO(out_statfs, rc = -EINVAL);
data->ioc_plen2 != sizeof(struct obd_uuid)) {
rc = -EINVAL;
goto out_statfs;
}
memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
if (type & LL_STATFS_LMV)
exp = sbi->ll_md_exp;
else if (type & LL_STATFS_LOV)
exp = sbi->ll_dt_exp;
else
GOTO(out_statfs, rc = -ENODEV);
else {
rc = -ENODEV;
goto out_statfs;
}
flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0;
rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags);
if (rc)
GOTO(out_statfs, rc);
goto out_statfs;
out_statfs:
if (buf)
obd_ioctl_freedata(buf, len);
......
......@@ -181,12 +181,14 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
LASSERT(vmpage != NULL);
io = ll_fault_io_init(vma, &env, &nest, vmpage->index, NULL);
if (IS_ERR(io))
GOTO(out, result = PTR_ERR(io));
if (IS_ERR(io)) {
result = PTR_ERR(io);
goto out;
}
result = io->ci_result;
if (result < 0)
GOTO(out_io, result);
goto out_io;
io->u.ci_fault.ft_mkwrite = 1;
io->u.ci_fault.ft_writable = 1;
......
......@@ -236,11 +236,15 @@ static int ll_get_name(struct dentry *dentry, char *name,
.ctx.actor = ll_nfs_get_name_filldir,
};
if (!dir || !S_ISDIR(dir->i_mode))
GOTO(out, rc = -ENOTDIR);
if (!dir || !S_ISDIR(dir->i_mode)) {
rc = -ENOTDIR;
goto out;
}
if (!dir->i_fop)
GOTO(out, rc = -EINVAL);
if (!dir->i_fop) {
rc = -EINVAL;
goto out;
}
mutex_lock(&dir->i_mutex);
rc = ll_dir_read(dir, &lgd.ctx);
......
......@@ -409,8 +409,10 @@ static int loop_thread(void *data)
lo->lo_state = LLOOP_BOUND;
env = cl_env_get(&refcheck);
if (IS_ERR(env))
GOTO(out, ret = PTR_ERR(env));
if (IS_ERR(env)) {
ret = PTR_ERR(env);
goto out;
}
lo->lo_env = env;
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,
if (magic != ll_iocontrol_magic)
return LLIOC_CONT;
if (disks == NULL)
GOTO(out1, err = -ENODEV);
if (disks == NULL) {
err = -ENODEV;
goto out1;
}
CWARN("Enter llop_ioctl\n");
......@@ -692,19 +696,25 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
file->f_dentry->d_inode)
break;
}
if (lo || !lo_free)
GOTO(out, err = -EBUSY);
if (lo || !lo_free) {
err = -EBUSY;
goto out;
}
lo = lo_free;
dev = MKDEV(lloop_major, lo->lo_number);
/* quit if the used pointer is writable */
if (put_user((long)old_encode_dev(dev), (long*)arg))
GOTO(out, err = -EFAULT);
if (put_user((long)old_encode_dev(dev), (long*)arg)) {
err = -EFAULT;
goto out;
}
bdev = blkdev_get_by_dev(dev, file->f_mode, NULL);
if (IS_ERR(bdev))
GOTO(out, err = PTR_ERR(bdev));
if (IS_ERR(bdev)) {
err = PTR_ERR(bdev);
goto out;
}
get_file(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,
int minor;
dev = old_decode_dev(arg);
if (MAJOR(dev) != lloop_major)
GOTO(out, err = -EINVAL);
if (MAJOR(dev) != lloop_major) {
err = -EINVAL;
goto out;
}
minor = MINOR(dev);
if (minor > max_loop - 1)
GOTO(out, err = -EINVAL);
if (minor > max_loop - 1) {
err = -EINVAL;
goto out;
}
lo = &loop_dev[minor];
if (lo->lo_state != LLOOP_BOUND)
GOTO(out, err = -EINVAL);
if (lo->lo_state != LLOOP_BOUND) {
err = -EINVAL;
goto out;
}
bdev = lo->lo_device;
err = loop_clr_fd(lo, bdev, 1);
......
......@@ -410,7 +410,8 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file,
/* easy - add more LRU slots. */
if (diff >= 0) {
atomic_add(diff, &cache->ccc_lru_left);
GOTO(out, rc = 0);
rc = 0;
goto out;
}
diff = -diff;
......@@ -997,8 +998,10 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
/* File operations stats */
sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
LPROCFS_STATS_FLAG_NONE);
if (sbi->ll_stats == NULL)
GOTO(out, err = -ENOMEM);
if (sbi->ll_stats == NULL) {
err = -ENOMEM;
goto out;
}
/* do counter init */
for (id = 0; id < LPROC_LL_FILE_OPCODES; id++) {
__u32 type = llite_opcode_table[id].type;
......@@ -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);
if (err)
GOTO(out, err);
goto out;
sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
LPROCFS_STATS_FLAG_NONE);
if (sbi->ll_ra_stats == NULL)
GOTO(out, err = -ENOMEM);
if (sbi->ll_ra_stats == NULL) {
err = -ENOMEM;
goto out;
}
for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++)
lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
......@@ -1029,12 +1034,12 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
sbi->ll_ra_stats);
if (err)
GOTO(out, err);
goto out;
err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb);
if (err)
GOTO(out, err);
goto out;
/* MDC info */
obd = class_name2obd(mdc);
......@@ -1044,20 +1049,22 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
LASSERT(obd->obd_type->typ_name != NULL);
dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
if (dir == NULL)
GOTO(out, err = -ENOMEM);
if (dir == NULL) {
err = -ENOMEM;
goto out;
}
snprintf(name, MAX_STRING_SIZE, "common_name");
lvars[0].fops = &llite_name_fops;
err = lprocfs_add_vars(dir, lvars, obd);
if (err)
GOTO(out, err);
goto out;
snprintf(name, MAX_STRING_SIZE, "uuid");
lvars[0].fops = &llite_uuid_fops;
err = lprocfs_add_vars(dir, lvars, obd);
if (err)
GOTO(out, err);
goto out;
/* OSC */
obd = class_name2obd(osc);
......@@ -1067,14 +1074,16 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
LASSERT(obd->obd_type->typ_name != NULL);
dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
if (dir == NULL)
GOTO(out, err = -ENOMEM);
if (dir == NULL) {
err = -ENOMEM;
goto out;
}
snprintf(name, MAX_STRING_SIZE, "common_name");
lvars[0].fops = &llite_name_fops;
err = lprocfs_add_vars(dir, lvars, obd);
if (err)
GOTO(out, err);
goto out;
snprintf(name, MAX_STRING_SIZE, "uuid");
lvars[0].fops = &llite_uuid_fops;
......
......@@ -523,8 +523,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
rc = ll_statahead_enter(parent, &dentry, 0);
if (rc == 1) {
if (dentry == save)
GOTO(out, retval = NULL);
GOTO(out, retval = dentry);
retval = NULL;
else
retval = dentry;
goto out;
}
}
......@@ -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,
lookup_flags, &req, ll_md_blocking_ast, 0);
ll_finish_md_op_data(op_data);
if (rc < 0)
GOTO(out, retval = ERR_PTR(rc));
if (rc < 0) {
retval = ERR_PTR(rc);
goto out;
}
rc = ll_lookup_it_finish(req, it, parent, &dentry);
if (rc != 0) {
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 &&
......@@ -563,9 +568,10 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
ll_lookup_finish_locks(it, dentry);
if (dentry == save)
GOTO(out, retval = NULL);
retval = NULL;
else
GOTO(out, retval = dentry);
retval = dentry;
goto out;
out:
if (req)
ptlrpc_req_finished(req);
......@@ -697,8 +703,10 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
request = it->d.lustre.it_data;
it_clear_disposition(it, DISP_ENQ_CREATE_REF);
rc = ll_prep_inode(&inode, request, dir->i_sb, it);
if (rc)
GOTO(out, inode = ERR_PTR(rc));
if (rc) {
inode = ERR_PTR(rc);
goto out;
}
LASSERT(ll_d_hlist_empty(&inode->i_dentry));
......@@ -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,
name->len, 0, opc, NULL);
if (IS_ERR(op_data))
GOTO(err_exit, err = PTR_ERR(op_data));
if (IS_ERR(op_data)) {
err = PTR_ERR(op_data);
goto err_exit;
}
err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
from_kuid(&init_user_ns, current_fsuid()),
......@@ -792,14 +802,14 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
cfs_curproc_cap_pack(), rdev, &request);
ll_finish_md_op_data(op_data);
if (err)
GOTO(err_exit, err);
goto err_exit;
ll_update_times(request, dir);
if (dchild) {
err = ll_prep_inode(&inode, request, dchild->d_sb, NULL);
if (err)
GOTO(err_exit, err);
goto err_exit;
d_instantiate(dchild, inode);
}
......@@ -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);
ll_finish_md_op_data(op_data);
if (err)
GOTO(out, err);
goto out;
ll_update_times(request, dir);
ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1);
......@@ -1028,7 +1038,8 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
if (body->eadatasize == 0) {
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
......@@ -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);
if (rc < 0) {
CERROR("obd_unpackmd: %d\n", rc);
GOTO(out, rc);
goto out;
}
LASSERT(rc >= sizeof(*lsm));
OBDO_ALLOC(oa);
if (oa == NULL)
GOTO(out_free_memmd, rc = -ENOMEM);
if (oa == NULL) {
rc = -ENOMEM;
goto out_free_memmd;
}
oa->o_oi = lsm->lsm_oi;
oa->o_mode = body->mode & S_IFMT;
......@@ -1070,7 +1083,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
if (body->valid & OBD_MD_FLOSSCAPA) {
rc = md_unpack_capa(ll_i2mdexp(dir), request, &RMF_CAPA2, &oc);
if (rc)
GOTO(out_free_memmd, rc);
goto out_free_memmd;
}
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,
rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
ll_finish_md_op_data(op_data);
if (rc)
GOTO(out, rc);
goto out;
ll_update_times(request, dir);
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)
break;
}
if (!found)
GOTO(out, rc = -ENOENT);
if (!found) {
rc = -ENOENT;
goto out;
}
CDEBUG(D_SEC, "found remote perm: %u/%u/%u/%u - %#x\n",
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,
* otherwise it will form small read RPC(< 1M), which hurt server
* performance a lot. */
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))
GOTO(out, ret = 0);
if (ret < 0 || ret < min_t(long, PTLRPC_MAX_BRW_PAGES, pages)) {
ret = 0;
goto out;
}
/* If the non-strided (ria_pages == 0) readahead window
* (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,
ras->ras_next_readahead = 0;
ras->ras_window_len = min(ra->ra_max_pages_per_file,
ra->ra_max_read_ahead_whole_pages);
GOTO(out_unlock, 0);
goto out_unlock;
}
}
if (zero) {
......@@ -1033,7 +1035,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
}
ras_reset(inode, ras, index);
ras->ras_consecutive_pages++;
GOTO(out_unlock, 0);
goto out_unlock;
} else {
ras->ras_consecutive_pages = 0;
ras->ras_consecutive_requests = 0;
......@@ -1058,7 +1060,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode,
ras_reset(inode, ras, index);
ras->ras_consecutive_pages++;
ras_stride_reset(ras);
GOTO(out_unlock, 0);
goto out_unlock;
}
} else if (stride_io_mode(ras)) {
/* 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,
* is not incremented and thus can't be used to trigger RA */
if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) {
ras->ras_window_len = RAS_INCREASE_STEP(inode);
GOTO(out_unlock, 0);
goto out_unlock;
}
/* Initially reset the stride window offset to next_readahead*/
......@@ -1136,8 +1138,10 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
LASSERT(ll_i2dtexp(inode) != NULL);
env = cl_env_nested_get(&nest);
if (IS_ERR(env))
GOTO(out, result = PTR_ERR(env));
if (IS_ERR(env)) {
result = PTR_ERR(env);
goto out;
}
clob = ll_i2info(inode)->lli_clob;
LASSERT(clob != NULL);
......@@ -1197,7 +1201,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc)
}
cl_env_nested_put(&nest, env);
GOTO(out, result);
goto out;
out:
if (result < 0) {
......
......@@ -441,7 +441,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
continue;
}
GOTO(out, result);
goto out;
}
iov_iter_advance(iter, result);
tot_bytes += result;
......
......@@ -637,8 +637,10 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
it = &minfo->mi_it;
req = entry->se_req;
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL)
GOTO(out, rc = -EFAULT);
if (body == NULL) {
rc = -EFAULT;
goto out;
}
child = entry->se_inode;
if (child == NULL) {
......@@ -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.
* SA can't handle it yet. */
if (body->valid & OBD_MD_MDS)
GOTO(out, rc = -EAGAIN);
if (body->valid & OBD_MD_MDS) {
rc = -EAGAIN;
goto out;
}
} else {
/*
* revalidate.
......@@ -665,12 +669,14 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
it->d.lustre.it_lock_handle = entry->se_handle;
rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL);
if (rc != 1)
GOTO(out, rc = -EAGAIN);
if (rc != 1) {
rc = -EAGAIN;
goto out;
}
rc = ll_prep_inode(&child, req, dir->i_sb, it);
if (rc)
GOTO(out, rc);
goto out;
CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
child, child->i_ino, child->i_generation);
......@@ -711,20 +717,23 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
if (unlikely(lli->lli_sai == NULL ||
lli->lli_sai->sai_generation != minfo->mi_generation)) {
spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -ESTALE);
rc = -ESTALE;
goto out;
} else {
sai = ll_sai_get(lli->lli_sai);
if (unlikely(!thread_is_running(&sai->sai_thread))) {
sai->sai_replied++;
spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -EBADFD);
rc = -EBADFD;
goto out;
}
entry = ll_sa_entry_get_byindex(sai, minfo->mi_cbdata);
if (entry == NULL) {
sai->sai_replied++;
spin_unlock(&lli->lli_sa_lock);
GOTO(out, rc = -EIDRM);
rc = -EIDRM;
goto out;
}
if (rc != 0) {
......@@ -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",
PFID(ll_inode2fid(dir)), pos, sai->sai_index,
rc, plli->lli_opendir_pid);
GOTO(out, rc);
goto out;
}
dp = page_address(page);
......@@ -1150,7 +1159,8 @@ static int ll_statahead_thread(void *arg)
if (unlikely(!thread_is_running(thread))) {
ll_release_page(page, 0);
GOTO(out, rc = 0);
rc = 0;
goto out;
}
/* If no window for metadata statahead, but there are
......@@ -1171,7 +1181,8 @@ static int ll_statahead_thread(void *arg)
if (unlikely(
!thread_is_running(thread))) {
ll_release_page(page, 0);
GOTO(out, rc = 0);
rc = 0;
goto out;
}
if (!sa_sent_full(sai))
......@@ -1203,8 +1214,10 @@ static int ll_statahead_thread(void *arg)
while (!sa_received_empty(sai))
ll_post_statahead(sai);
if (unlikely(!thread_is_running(thread)))
GOTO(out, rc = 0);
if (unlikely(!thread_is_running(thread))) {
rc = 0;
goto out;
}
if (sai->sai_sent == sai->sai_replied &&
sa_received_empty(sai))
......@@ -1222,7 +1235,8 @@ static int ll_statahead_thread(void *arg)
}
spin_unlock(&plli->lli_agl_lock);
GOTO(out, rc = 0);
rc = 0;
goto out;
} else if (1) {
/*
* chain is exhausted.
......@@ -1422,7 +1436,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
rc = LS_FIRST_DOT_DE;
ll_release_page(page, 0);
GOTO(out, rc);
goto out;
}
pos = le64_to_cpu(dp->ldp_hash_end);
if (pos == MDS_DIR_END_OFF) {
......@@ -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". */
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. */
GOTO(out, rc = -EAGAIN);
rc = -EAGAIN;
goto out;
}
sai = ll_sai_alloc();
if (sai == NULL)
GOTO(out, rc = -ENOMEM);
if (sai == NULL) {
rc = -ENOMEM;
goto out;
}
sai->sai_ls_all = (rc == LS_FIRST_DOT_DE);
sai->sai_inode = igrab(dir);
if (unlikely(sai->sai_inode == NULL)) {
CWARN("Do not start stat ahead on dying inode "DFID"\n",
PFID(&lli->lli_fid));
GOTO(out, rc = -ESTALE);
rc = -ESTALE;
goto out;
}
/* 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,
PFID(&lli->lli_fid), PFID(&nlli->lli_fid));
dput(parent);
iput(sai->sai_inode);
GOTO(out, rc = -EAGAIN);
rc = -EAGAIN;
goto out;
}
CDEBUG(D_READA, "start statahead thread: sai %p, parent %.*s\n",
......
......@@ -77,21 +77,23 @@ static int ll_readlink_internal(struct inode *inode,
if (rc) {
if (rc != -ENOENT)
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);
LASSERT(body != NULL);
if ((body->valid & OBD_MD_LINKNAME) == 0) {
CERROR("OBD_MD_LINKNAME not set on reply\n");
GOTO(failed, rc = -EPROTO);
rc = -EPROTO;
goto failed;
}
LASSERT(symlen != 0);
if (body->eadatasize != symlen) {
CERROR("inode %lu: symlink length %d not expected %d\n",
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);
......@@ -100,7 +102,8 @@ static int ll_readlink_internal(struct inode *inode,
/* not full/NULL terminated */
CERROR("inode %lu: symlink not NULL terminated string"
"of length %d\n", inode->i_ino, symlen - 1);
GOTO(failed, rc = -EPROTO);
rc = -EPROTO;
goto failed;
}
OBD_ALLOC(lli->lli_symlink_name, symlen);
......
......@@ -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
* 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,
* in ll_page_mkwrite0. Thus we return -ENODATA
* to handle both cases
*/
GOTO(out, result = -ENODATA);
result = -ENODATA;
goto out;
}
}
page = cl_page_find(env, obj, fio->ft_index, vmpage, CPT_CACHEABLE);
if (IS_ERR(page))
GOTO(out, result = PTR_ERR(page));
if (IS_ERR(page)) {
result = PTR_ERR(page);
goto out;
}
/* if page is going to be written, we should add this page into cache
* earlier. */
......@@ -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? */
if (result == -EDQUOT)
result = -ENOSPC;
GOTO(out, result);
goto out;
} else
cl_page_disown(env, io, page);
}
......
......@@ -364,7 +364,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
if (rc == -EAGAIN)
goto getxattr_nocache;
if (rc < 0)
GOTO(out_xattr, rc);
goto out_xattr;
/* Add "system.posix_acl_access" to the list */
if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
......@@ -375,7 +375,8 @@ int ll_getxattr_common(struct inode *inode, const char *name,
sizeof(XATTR_NAME_ACL_ACCESS));
rc += sizeof(XATTR_NAME_ACL_ACCESS);
} else {
GOTO(out_xattr, rc = -ERANGE);
rc = -ERANGE;
goto out_xattr;
}
}
} else {
......@@ -387,29 +388,36 @@ int ll_getxattr_common(struct inode *inode, const char *name,
capa_put(oc);
if (rc < 0)
GOTO(out_xattr, rc);
goto out_xattr;
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
LASSERT(body);
/* only detect the xattr size */
if (size == 0)
GOTO(out, rc = body->eadatasize);
if (size == 0) {
rc = body->eadatasize;
goto out;
}
if (size < body->eadatasize) {
CERROR("server bug: replied size %u > %u\n",
body->eadatasize, (int)size);
GOTO(out, rc = -ERANGE);
rc = -ERANGE;
goto out;
}
if (body->eadatasize == 0)
GOTO(out, rc = -ENODATA);
if (body->eadatasize == 0) {
rc = -ENODATA;
goto out;
}
/* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
body->eadatasize);
if (!xdata)
GOTO(out, rc = -EFAULT);
if (!xdata) {
rc = -EFAULT;
goto out;
}
memcpy(buffer, xdata, body->eadatasize);
rc = body->eadatasize;
......@@ -421,14 +429,16 @@ int ll_getxattr_common(struct inode *inode, const char *name,
acl = lustre_posix_acl_xattr_2ext(
(posix_acl_xattr_header *)buffer, rc);
if (IS_ERR(acl))
GOTO(out, rc = PTR_ERR(acl));
if (IS_ERR(acl)) {
rc = PTR_ERR(acl);
goto out;
}
rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
xattr_type, acl);
if (unlikely(rc < 0)) {
lustre_ext_acl_xattr_free(acl);
GOTO(out, rc);
goto out;
}
}
#endif
......@@ -476,7 +486,8 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
if (size == 0 && S_ISDIR(inode->i_mode)) {
/* XXX directory EA is fix for now, optimize to save
* RPC transfer */
GOTO(out, rc = sizeof(struct lov_user_md));
rc = sizeof(struct lov_user_md);
goto out;
}
lsm = ccc_inode_lsm_get(inode);
......@@ -496,7 +507,7 @@ ssize_t ll_getxattr(struct dentry *dentry, const char *name,
ccc_inode_lsm_put(inode, lsm);
if (rc < 0)
GOTO(out, rc);
goto out;
if (size == 0) {
/* used to call ll_get_max_mdsize() forward to get
......@@ -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
* size */
rc = lmmsize;
GOTO(out, rc);
goto out;
}
if (size < lmmsize) {
CERROR("server bug: replied size %d > %d for %s (%s)\n",
lmmsize, (int)size, dentry->d_name.name, name);
GOTO(out, rc = -ERANGE);
rc = -ERANGE;
goto out;
}
lump = (struct lov_user_md *)buffer;
......@@ -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);
if (rc < 0)
GOTO(out, rc);
goto out;
if (buffer != NULL) {
struct ll_sb_info *sbi = ll_i2sbi(inode);
......@@ -582,7 +594,8 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
}
if (rc2 < 0) {
GOTO(out, rc2 = 0);
rc2 = 0;
goto out;
} else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) {
const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 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)
rc = ll_xattr_find_get_lock(inode, oit, &req);
if (rc)
GOTO(out_no_unlock, rc);
goto out_no_unlock;
/* Do we have the data at this point? */
if (ll_xattr_cache_valid(lli)) {
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. */
if (unlikely(req == NULL)) {
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) {
......@@ -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 */
if (rc == -ERANGE)
rc = -EAGAIN;
GOTO(out_destroy, rc);
goto out_destroy;
}
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL) {
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 */
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)
body->max_mdsize * sizeof(__u32));
if (xdata == NULL || xval == NULL || xsizes == NULL) {
CERROR("wrong setxattr reply\n");
GOTO(out_destroy, rc = -EPROTO);
rc = -EPROTO;
goto out_destroy;
}
xtail = xdata + body->eadatasize;
......@@ -435,7 +439,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit)
}
if (rc < 0) {
ll_xattr_cache_destroy_locked(lli);
GOTO(out_destroy, rc);
goto out_destroy;
}
xdata += strlen(xdata) + 1;
xval += *xsizes;
......@@ -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);
GOTO(out_maybe_drop, rc);
goto out_maybe_drop;
out_maybe_drop:
ll_intent_drop_lock(oit);
......@@ -528,7 +532,7 @@ int ll_xattr_cache_get(struct inode *inode,
size ? buffer : NULL, size);
}
GOTO(out, rc);
goto out;
out:
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