diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/llite')
25 files changed, 724 insertions, 955 deletions
diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index dff0c0486e77..f493e0740004 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o -obj-$(CONFIG_LUSTRE_FS) += llite_lloop.o +obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ rw.o lproc_llite.o namei.o symlink.o llite_mmap.o \ xattr.o remote_perm.o llite_rmtacl.o llite_capa.o \ diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index ff0d085077c8..e7629be39739 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -59,11 +59,11 @@ static void free_dentry_data(struct rcu_head *head) static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; - ENTRY; + LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) /* NFS copies the de->d_op methods (bug 4655) */ - RETURN_EXIT; + return; if (lld->lld_it) { ll_intent_release(lld->lld_it); @@ -73,8 +73,6 @@ static void ll_release(struct dentry *de) LASSERT(lld->lld_mnt_count == 0); de->d_fsdata = NULL; call_rcu(&lld->lld_rcu_head, free_dentry_data); - - EXIT; } /* Compare if two dentries are the same. Don't match if the existing dentry @@ -84,17 +82,14 @@ static void ll_release(struct dentry *de) * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so * lock_match() fails) and we spin around real_lookup(). */ -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) { - ENTRY; - if (len != name->len) - RETURN(1); + return 1; if (memcmp(str, name->name, len)) - RETURN(1); + return 1; CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n", name->len, name->name, dentry, dentry->d_flags, @@ -102,12 +97,12 @@ int ll_dcompare(const struct dentry *parent, const struct inode *pinode, /* mountpoint is always valid */ if (d_mountpoint((struct dentry *)dentry)) - RETURN(0); + return 0; if (d_lustre_invalid(dentry)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static inline int return_if_equal(struct ldlm_lock *lock, void *data) @@ -128,22 +123,21 @@ static int find_cbdata(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct lov_stripe_md *lsm; int rc = 0; - ENTRY; LASSERT(inode); rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), return_if_equal, NULL); if (rc != 0) - RETURN(rc); + return rc; lsm = ccc_inode_lsm_get(inode); if (lsm == NULL) - RETURN(rc); + return rc; rc = obd_find_cbdata(sbi->ll_dt_exp, lsm, return_if_equal, NULL); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } /** @@ -155,7 +149,6 @@ static int find_cbdata(struct inode *inode) */ static int ll_ddelete(const struct dentry *de) { - ENTRY; LASSERT(de); CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n", @@ -179,13 +172,12 @@ static int ll_ddelete(const struct dentry *de) #endif if (d_lustre_invalid((struct dentry *)de)) - RETURN(1); - RETURN(0); + return 1; + return 0; } static int ll_set_dd(struct dentry *de) { - ENTRY; LASSERT(de != NULL); CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n", @@ -204,11 +196,11 @@ static int ll_set_dd(struct dentry *de) OBD_FREE_PTR(lld); spin_unlock(&de->d_lock); } else { - RETURN(-ENOMEM); + return -ENOMEM; } } - RETURN(0); + return 0; } int ll_dops_init(struct dentry *de, int block, int init_sa) @@ -260,8 +252,6 @@ void ll_intent_drop_lock(struct lookup_intent *it) void ll_intent_release(struct lookup_intent *it) { - ENTRY; - CDEBUG(D_INFO, "intent %p released\n", it); ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ @@ -275,14 +265,12 @@ void ll_intent_release(struct lookup_intent *it) it->d.lustre.it_disposition = 0; it->d.lustre.it_data = NULL; - EXIT; } void ll_invalidate_aliases(struct inode *inode) { struct dentry *dentry; struct ll_d_hlist_node *p; - ENTRY; LASSERT(inode != NULL); @@ -296,18 +284,17 @@ void ll_invalidate_aliases(struct inode *inode) dentry->d_name.name, dentry, dentry->d_parent, dentry->d_inode, dentry->d_flags); - if (dentry->d_name.len == 1 && dentry->d_name.name[0] == '/') { - CERROR("called on root (?) dentry=%p, inode=%p " - "ino=%lu\n", dentry, inode, inode->i_ino); + if (unlikely(dentry == dentry->d_sb->s_root)) { + CERROR("%s: called on root dentry=%p, fid="DFID"\n", + ll_get_fsname(dentry->d_sb, NULL, 0), + dentry, PFID(ll_inode2fid(inode))); lustre_dump_dentry(dentry, 1); - libcfs_debug_dumpstack(NULL); + dump_stack(); } d_lustre_invalidate(dentry, 0); } ll_unlock_dcache(inode); - - EXIT; } int ll_revalidate_it_finish(struct ptlrpc_request *request, @@ -315,17 +302,16 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, struct dentry *de) { int rc = 0; - ENTRY; if (!request) - RETURN(0); + return 0; if (it_disposition(it, DISP_LOOKUP_NEG)) - RETURN(-ENOENT); + return -ENOENT; rc = ll_prep_inode(&de->d_inode, request, NULL, it); - RETURN(rc); + return rc; } void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) @@ -370,7 +356,6 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, struct inode *parent = de->d_parent->d_inode; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name, LL_IT2STR(it)); @@ -383,10 +368,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, away this negative dentry and actually do the request to kernel to create whatever needs to be created (if possible)*/ if (it && (it->it_op & IT_CREAT)) - RETURN(0); + return 0; if (d_lustre_invalid(de)) - RETURN(0); + return 0; ibits = MDS_INODELOCK_UPDATE; rc = ll_have_md_lock(parent, &ibits, LCK_MINMODE); @@ -413,7 +398,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, LASSERT(it); if (it->it_op == IT_LOOKUP && !d_lustre_invalid(de)) - RETURN(1); + return 1; if (it->it_op == IT_OPEN) { struct inode *inode = de->d_inode; @@ -460,7 +445,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if it would be, we'll reopen the open request to MDS later during file open path */ mutex_unlock(&lli->lli_och_mutex); - RETURN(1); + return 1; } else { mutex_unlock(&lli->lli_och_mutex); } @@ -479,7 +464,7 @@ do_lock: de->d_name.name, de->d_name.len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (!IS_POSIXACL(parent) || !exp_connect_umask(exp)) it->it_create_mode &= ~current_umask(); @@ -566,7 +551,7 @@ out: mark: if (it != NULL && it->it_op == IT_GETATTR && rc > 0) ll_statahead_mark(parent, de); - RETURN(rc); + return rc; /* * This part is here to combat evil-evil race in real_lookup on 2.6 @@ -598,7 +583,7 @@ do_lookup: LUSTRE_OPC_CREATE : LUSTRE_OPC_ANY), NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_intent_lock(exp, op_data, NULL, 0, it, 0, &req, ll_md_blocking_ast, 0); @@ -639,14 +624,13 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) struct inode *parent = dentry->d_parent->d_inode; int unplug = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,flags=%u\n", dentry->d_name.name, flags); if (!(flags & (LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE)) && ll_need_statahead(parent, dentry) > 0) { if (flags & LOOKUP_RCU) - RETURN(-ECHILD); + return -ECHILD; if (dentry->d_inode == NULL) unplug = 1; @@ -654,7 +638,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) ll_statahead_mark(parent, dentry); } - RETURN(1); + return 1; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 23c61fe81965..09844be5eec4 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -41,14 +41,13 @@ #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/mm.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/buffer_head.h> // for wait_on_buffer #include <linux/pagevec.h> +#include <linux/prefetch.h> #define DEBUG_SUBSYSTEM S_LLITE -#include <lustre/lustre_idl.h> #include <obd_support.h> #include <obd_class.h> #include <lustre_lib.h> @@ -158,7 +157,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) int npages; int i; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash "LPU64"\n", inode->i_ino, inode->i_generation, inode, hash); @@ -239,7 +237,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) if (page_pool != &page0) OBD_FREE(page_pool, sizeof(struct page *) * max_pages); - EXIT; return rc; } @@ -355,15 +352,12 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, rc = md_lock_match(ll_i2sbi(dir)->ll_md_exp, LDLM_FL_BLOCK_GRANTED, ll_inode2fid(dir), LDLM_IBITS, &policy, mode, &lockh); if (!rc) { - struct ldlm_enqueue_info einfo = {.ei_type = LDLM_IBITS, - .ei_mode = mode, - .ei_cb_bl = - ll_md_blocking_ast, - .ei_cb_cp = - ldlm_completion_ast, - .ei_cb_gl = NULL, - .ei_cb_wg = NULL, - .ei_cbdata = NULL}; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = mode, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; struct lookup_intent it = { .it_op = IT_READDIR }; struct ptlrpc_request *request; struct md_op_data *op_data; @@ -482,19 +476,17 @@ fail: goto out_unlock; } -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir) +int ll_dir_read(struct inode *inode, struct dir_context *ctx) { struct ll_inode_info *info = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = *_pos; + __u64 pos = ctx->pos; int api32 = ll_need_32bit_api(sbi); int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; struct page *page; struct ll_dir_chain chain; int done = 0; int rc = 0; - ENTRY; ll_dir_chain_init(&chain); @@ -547,12 +539,14 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, fid_le_to_cpu(&fid, &ent->lde_fid); ino = cl_fid_build_ino(&fid, api32); type = ll_dirent_type_get(ent); + ctx->pos = lhash; /* For 'll_nfs_get_name_filldir()', it will try * to access the 'ent' through its 'lde_name', - * so the parameter 'name' for 'filldir()' must - * be part of the 'ent'. */ - done = filldir(cookie, ent->lde_name, namelen, - lhash, ino, type); + * so the parameter 'name' for 'ctx->actor()' + * must be part of the 'ent'. + */ + done = !dir_emit(ctx, ent->lde_name, + namelen, ino, type); } next = le64_to_cpu(dp->ldp_hash_end); if (!done) { @@ -593,56 +587,49 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, } } - *_pos = pos; + ctx->pos = pos; ll_dir_chain_fini(&chain); - RETURN(rc); + return rc; } -static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) +static int ll_readdir(struct file *filp, struct dir_context *ctx) { struct inode *inode = filp->f_dentry->d_inode; struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = lfd->lfd_pos; int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; int api32 = ll_need_32bit_api(sbi); int rc; - struct path path; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu " " 32bit_api %d\n", inode->i_ino, inode->i_generation, - inode, (unsigned long)pos, i_size_read(inode), api32); + inode, (unsigned long)lfd->lfd_pos, i_size_read(inode), api32); - if (pos == MDS_DIR_END_OFF) + if (lfd->lfd_pos == MDS_DIR_END_OFF) /* * end-of-file. */ GOTO(out, rc = 0); - rc = ll_dir_read(inode, &pos, cookie, filldir); - lfd->lfd_pos = pos; - if (pos == MDS_DIR_END_OFF) { + ctx->pos = lfd->lfd_pos; + rc = ll_dir_read(inode, ctx); + lfd->lfd_pos = ctx->pos; + if (ctx->pos == MDS_DIR_END_OFF) { if (api32) - filp->f_pos = LL_DIR_END_OFF_32BIT; + ctx->pos = LL_DIR_END_OFF_32BIT; else - filp->f_pos = LL_DIR_END_OFF; + ctx->pos = LL_DIR_END_OFF; } else { if (api32 && hash64) - filp->f_pos = pos >> 32; - else - filp->f_pos = pos; + ctx->pos >>= 32; } filp->f_version = inode->i_version; - path.mnt = filp->f_path.mnt; - path.dentry = filp->f_dentry; - touch_atime(&path); out: if (!rc) ll_stats_ops_tally(sbi, LPROC_LL_READDIR, 1); - RETURN(rc); + return rc; } int ll_send_mgc_param(struct obd_export *mgc, char *string) @@ -673,8 +660,6 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, int mode; int err; - ENTRY; - mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; op_data = ll_prep_md_op_data(NULL, dir, NULL, filename, strlen(filename), mode, LUSTRE_OPC_MKDIR, @@ -684,7 +669,8 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, op_data->op_cli_flags |= CLI_SET_MEA; err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), 0, &request); ll_finish_md_op_data(op_data); if (err) @@ -704,7 +690,6 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, struct lustre_sb_info *lsi = s2lsi(inode->i_sb); struct obd_device *mgc = lsi->lsi_mgc; int lum_size; - ENTRY; if (lump != NULL) { /* @@ -731,7 +716,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, " %#08x != %#08x nor %#08x\n", lump->lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); - RETURN(-EINVAL); + return -EINVAL; } } } else { @@ -741,7 +726,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (lump != NULL && lump->lmm_magic == cpu_to_le32(LMV_USER_MAGIC)) op_data->op_cli_flags |= CLI_SET_MEA; @@ -797,7 +782,7 @@ end: if (param != NULL) OBD_FREE(param, MGS_PARAM_MAXLEN); } - RETURN(rc); + return rc; } int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, @@ -812,13 +797,13 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr(sbi->ll_md_exp, op_data, &req); @@ -878,12 +863,11 @@ int ll_get_mdt_idx(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct md_op_data *op_data; int rc, mdtidx; - ENTRY; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_flags |= MF_GET_MDT_IDX; rc = md_getattr(sbi->ll_md_exp, op_data, NULL); @@ -891,7 +875,7 @@ int ll_get_mdt_idx(struct inode *inode) ll_finish_md_op_data(op_data); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name: %d\n", rc); - RETURN(rc); + return rc; } return mdtidx; } @@ -912,7 +896,6 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* Forge a hsm_progress based on data from copy. */ hpk.hpk_fid = copy->hc_hai.hai_fid; @@ -962,7 +945,7 @@ progress: rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } /** @@ -985,7 +968,6 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* If you modify the logic here, also check llapi_hsm_copy_end(). */ /* Take care: copy->hc_hai.hai_action, len, gid and data are not @@ -1062,7 +1044,7 @@ progress: rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } @@ -1090,7 +1072,6 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) int id = qctl->qc_id; int valid = qctl->qc_valid; int rc = 0; - ENTRY; switch (cmd) { case LUSTRE_Q_INVALIDATE: @@ -1101,32 +1082,34 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case Q_SETINFO: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; break; case Q_GETQUOTA: - if (((type == USRQUOTA && current_euid() != id) || - (type == GRPQUOTA && !in_egroup_p(id))) && + if (((type == USRQUOTA && + uid_eq(current_euid(), make_kuid(&init_user_ns, id))) || + (type == GRPQUOTA && + !in_egroup_p(make_kgid(&init_user_ns, id)))) && (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT)) - RETURN(-EPERM); + return -EPERM; break; case Q_GETINFO: break; default: CERROR("unsupported quotactl op: %#x\n", cmd); - RETURN(-ENOTTY); + return -ENOTTY; } if (valid != QC_GENERAL) { if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (cmd == Q_GETINFO) qctl->qc_cmd = Q_GETOINFO; else if (cmd == Q_GETQUOTA) qctl->qc_cmd = Q_GETOQUOTA; else - RETURN(-EINVAL); + return -EINVAL; switch (valid) { case QC_MDTIDX: @@ -1151,7 +1134,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) } if (rc) - RETURN(rc); + return rc; qctl->qc_cmd = cmd; } else { @@ -1159,7 +1142,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) OBD_ALLOC_PTR(oqctl); if (oqctl == NULL) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(sbi->ll_md_exp, oqctl); @@ -1169,7 +1152,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) obd_quotactl(sbi->ll_md_exp, oqctl); } OBD_FREE_PTR(oqctl); - RETURN(rc); + return rc; } /* If QIF_SPACE is not set, client should collect the * space usage from OSSs by itself */ @@ -1216,7 +1199,7 @@ out: OBD_FREE_PTR(oqctl); } - RETURN(rc); + return rc; } static char * @@ -1249,7 +1232,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_ioctl_data *data; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -1262,10 +1244,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch(cmd) { case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly * network encode the arg field. @@ -1277,10 +1259,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; return 0; } @@ -1293,7 +1275,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; filename = data->ioc_inlbuf1; @@ -1317,7 +1299,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) GOTO(out_free, rc); } ptlrpc_req_finished(request); - EXIT; out_free: obd_ioctl_freedata(buf, len); return rc; @@ -1333,7 +1314,7 @@ out_free: rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL || @@ -1364,7 +1345,7 @@ out_free: rc = ll_dir_setdirstripe(inode, lum, filename); lmv_out_free: obd_ioctl_freedata(buf, len); - RETURN(rc); + return rc; } case LL_IOC_LOV_SETSTRIPE: { @@ -1380,11 +1361,11 @@ lmv_out_free: sizeof(lumv3p->lmm_objects[0])); /* first try with v1 which is smaller than v3 */ if (copy_from_user(lumv1, lumv1p, sizeof(*lumv1))) - RETURN(-EFAULT); + return -EFAULT; if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) ) { if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3))) - RETURN(-EFAULT); + return -EFAULT; } if (inode->i_sb->s_root == file->f_dentry) @@ -1393,7 +1374,7 @@ lmv_out_free: /* in v1 and v3 cases lumv1 points to data */ rc = ll_dir_setstripe(inode, lumv1, set_default); - RETURN(rc); + return rc; } case LL_IOC_LMV_GETSTRIPE: { struct lmv_user_md *lump = (struct lmv_user_md *)arg; @@ -1404,10 +1385,10 @@ lmv_out_free: int mdtindex; if (copy_from_user(&lum, lump, sizeof(struct lmv_user_md))) - RETURN(-EFAULT); + return -EFAULT; if (lum.lum_magic != LMV_MAGIC_V1) - RETURN(-EINVAL); + return -EINVAL; lum_size = lmv_user_md_size(1, LMV_MAGIC_V1); OBD_ALLOC(tmp, lum_size); @@ -1430,7 +1411,7 @@ lmv_out_free: free_lmv: if (tmp) OBD_FREE(tmp, lum_size); - RETURN(rc); + return rc; } case LL_IOC_REMOVE_ENTRY: { char *filename = NULL; @@ -1447,7 +1428,7 @@ free_lmv: filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); namelen = strlen(filename); if (namelen < 1) @@ -1457,12 +1438,12 @@ free_lmv: out_rmdir: if (filename) ll_putname(filename); - RETURN(rc); + return rc; } case LL_IOC_LOV_SWAP_LAYOUTS: - RETURN(-EPERM); + return -EPERM; case LL_IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); case LL_IOC_LOV_GETSTRIPE: case LL_IOC_MDC_GETINFO: case IOC_MDC_GETFILEINFO: @@ -1478,7 +1459,7 @@ out_rmdir: cmd == IOC_MDC_GETFILESTRIPE) { filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); rc = ll_lov_getstripe_ea_info(inode, filename, &lmm, &lmmsize, &request); @@ -1539,7 +1520,6 @@ out_rmdir: GOTO(out_req, rc = -EFAULT); } - EXIT; out_req: ptlrpc_req_finished(request); if (filename) @@ -1559,9 +1539,11 @@ out_rmdir: rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; OBD_ALLOC_LARGE(lmm, lmmsize); + if (lmm == NULL) + return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) GOTO(free_lmm, rc = -EFAULT); @@ -1602,7 +1584,6 @@ out_rmdir: if (copy_to_user(&lumd->lmd_st, &st, sizeof(st))) GOTO(free_lsm, rc = -EFAULT); - EXIT; free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); free_lmm: @@ -1610,7 +1591,7 @@ out_rmdir: return rc; } case OBD_IOC_LLOG_CATINFO: { - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } case OBD_IOC_QUOTACHECK: { struct obd_quotactl *oqctl; @@ -1618,11 +1599,11 @@ out_rmdir: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; oqctl->qc_type = arg; rc = obd_quotacheck(sbi->ll_md_exp, oqctl); if (rc < 0) { @@ -1642,11 +1623,11 @@ out_rmdir: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(check); if (!check) - RETURN(-ENOMEM); + return -ENOMEM; rc = obd_iocontrol(cmd, sbi->ll_md_exp, 0, (void *)check, NULL); @@ -1669,7 +1650,7 @@ out_rmdir: } out_poll: OBD_FREE_PTR(check); - RETURN(rc); + return rc; } #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) case LL_IOC_QUOTACTL_18: { @@ -1680,7 +1661,7 @@ out_rmdir: OBD_ALLOC_PTR(qctl_18); if (!qctl_18) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(qctl_20); if (!qctl_20) @@ -1720,7 +1701,7 @@ out_rmdir: OBD_FREE_PTR(qctl_20); out_quotactl_18: OBD_FREE_PTR(qctl_18); - RETURN(rc); + return rc; } #else #warning "remove old LL_IOC_QUOTACTL_18 compatibility code" @@ -1730,7 +1711,7 @@ out_rmdir: OBD_ALLOC_PTR(qctl); if (!qctl) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(qctl, (void *)arg, sizeof(*qctl))) GOTO(out_quotactl, rc = -EFAULT); @@ -1742,13 +1723,13 @@ out_rmdir: out_quotactl: OBD_FREE_PTR(qctl); - RETURN(rc); + return rc; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); #ifdef CONFIG_FS_POSIX_ACL case LL_IOC_RMTACL: { if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -1759,9 +1740,9 @@ out_rmdir: rc = rct_add(&sbi->ll_rct, current_pid(), arg); if (!rc) fd->fd_flags |= LL_FILE_RMTACL; - RETURN(rc); + return rc; } else - RETURN(0); + return 0; } #endif case LL_IOC_GETOBDCOUNT: { @@ -1769,7 +1750,7 @@ out_rmdir: struct obd_export *exp; if (copy_from_user(&count, (int *)arg, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; /* get ost count when count is zero, get mdt count otherwise */ exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; @@ -1778,41 +1759,41 @@ out_rmdir: KEY_TGT_COUNT, &vallen, &count, NULL); if (rc) { CERROR("get target count failed: %d\n", rc); - RETURN(rc); + return rc; } if (copy_to_user((int *)arg, &count, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case LL_IOC_PATH2FID: if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); - RETURN(0); + return -EFAULT; + return 0; case LL_IOC_GET_CONNECT_FLAGS: { - RETURN(obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void*)arg)); + return obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void*)arg); } case OBD_IOC_CHANGELOG_SEND: case OBD_IOC_CHANGELOG_CLEAR: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct ioc_changelog)); - RETURN(rc); + return rc; case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_HSM_REQUEST: { struct hsm_user_request *hur; int totalsize; OBD_ALLOC_PTR(hur); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* We don't know the true size yet; copy the fixed-size part */ if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { OBD_FREE_PTR(hur); - RETURN(-EFAULT); + return -EFAULT; } /* Compute the whole struct size */ @@ -1820,12 +1801,12 @@ out_rmdir: OBD_FREE_PTR(hur); OBD_ALLOC_LARGE(hur, totalsize); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* Copy the whole struct */ if (copy_from_user(hur, (void *)arg, totalsize)) { OBD_FREE_LARGE(hur, totalsize); - RETURN(-EFAULT); + return -EFAULT; } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), totalsize, @@ -1833,14 +1814,14 @@ out_rmdir: OBD_FREE_LARGE(hur, totalsize); - RETURN(rc); + return rc; } case LL_IOC_HSM_PROGRESS: { struct hsm_progress_kernel hpk; struct hsm_progress hp; if (copy_from_user(&hp, (void *)arg, sizeof(hp))) - RETURN(-EFAULT); + return -EFAULT; hpk.hpk_fid = hp.hp_fid; hpk.hpk_cookie = hp.hp_cookie; @@ -1853,12 +1834,12 @@ out_rmdir: * reported to Lustre root */ rc = obd_iocontrol(cmd, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } case LL_IOC_HSM_CT_START: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct lustre_kernelcomm)); - RETURN(rc); + return rc; case LL_IOC_HSM_COPY_START: { struct hsm_copy *copy; @@ -1866,10 +1847,10 @@ out_rmdir: OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_start(inode->i_sb, copy); @@ -1877,7 +1858,7 @@ out_rmdir: rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } case LL_IOC_HSM_COPY_END: { struct hsm_copy *copy; @@ -1885,10 +1866,10 @@ out_rmdir: OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_end(inode->i_sb, copy); @@ -1896,11 +1877,10 @@ out_rmdir: rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } default: - RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, (void *)arg); } } @@ -1911,7 +1891,6 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) struct ll_sb_info *sbi = ll_i2sbi(inode); int api32 = ll_need_32bit_api(sbi); loff_t ret = -EINVAL; - ENTRY; mutex_lock(&inode->i_mutex); switch (origin) { @@ -1957,14 +1936,12 @@ out: int ll_dir_open(struct inode *inode, struct file *file) { - ENTRY; - RETURN(ll_file_open(inode, file)); + return ll_file_open(inode, file); } int ll_dir_release(struct inode *inode, struct file *file) { - ENTRY; - RETURN(ll_file_release(inode, file)); + return ll_file_release(inode, file); } struct file_operations ll_dir_operations = { @@ -1972,7 +1949,7 @@ struct file_operations ll_dir_operations = { .open = ll_dir_open, .release = ll_dir_release, .read = generic_read_dir, - .readdir = ll_readdir, + .iterate = ll_readdir, .unlocked_ioctl = ll_dir_ioctl, .fsync = ll_fsync, }; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index ed1e3f7b4e58..253f02688f4f 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -55,6 +55,8 @@ struct ll_file_data *ll_file_data_get(void) struct ll_file_data *fd; OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO); + if (fd == NULL) + return NULL; fd->fd_write_failed = false; return fd; } @@ -93,8 +95,6 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, struct obd_client_handle *och) { - ENTRY; - op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME | ATTR_ATIME_SET | ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME | ATTR_CTIME_SET; @@ -111,7 +111,6 @@ out: ll_pack_inode2opdata(inode, op_data, &och->och_fh); ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); - EXIT; } static int ll_close_inode_openhandle(struct obd_export *md_exp, @@ -124,7 +123,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, struct obd_device *obd = class_exp2obd(exp); int epoch_close = 1; int rc; - ENTRY; if (obd == NULL) { /* @@ -178,9 +176,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, inode->i_ino, rc); } - EXIT; out: - if (exp_connect_som(exp) && !epoch_close && S_ISREG(inode->i_mode) && (och->och_flags & FMODE_WRITE)) { ll_queue_done_writing(inode, LLIF_DONE_WRITING); @@ -202,7 +198,6 @@ int ll_md_real_close(struct inode *inode, int flags) struct obd_client_handle *och; __u64 *och_usecount; int rc = 0; - ENTRY; if (flags & FMODE_WRITE) { och_p = &lli->lli_mds_write_och; @@ -220,7 +215,7 @@ int ll_md_real_close(struct inode *inode, int flags) if (*och_usecount) { /* There are still users of this handle, so skip freeing it. */ mutex_unlock(&lli->lli_och_mutex); - RETURN(0); + return 0; } och=*och_p; *och_p = NULL; @@ -232,7 +227,7 @@ int ll_md_real_close(struct inode *inode, int flags) inode, och); } - RETURN(rc); + return rc; } int ll_md_close(struct obd_export *md_exp, struct inode *inode, @@ -241,7 +236,6 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; /* clear group lock, if present */ if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED)) @@ -287,7 +281,7 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, ll_file_data_put(fd); ll_capa_close(inode); - RETURN(rc); + return rc; } /* While this returns an error code, fput() the caller does not, so we need @@ -301,7 +295,6 @@ int ll_file_release(struct inode *inode, struct file *file) struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -335,7 +328,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = NULL; ll_file_data_put(fd); - RETURN(0); + return 0; } if (!S_ISDIR(inode->i_mode)) { @@ -348,7 +341,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val)) libcfs_debug_dumplog(); - RETURN(rc); + return rc; } static int ll_intent_file_open(struct file *file, void *lmm, @@ -362,10 +355,9 @@ static int ll_intent_file_open(struct file *file, void *lmm, struct ptlrpc_request *req; __u32 opc = LUSTRE_OPC_ANY; int rc; - ENTRY; if (!parent) - RETURN(-ENOENT); + return -ENOENT; /* Usually we come here only for NFSD, and we want open lock. But we can also get here with pre 2.6.15 patchless kernels, and in @@ -386,7 +378,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, file->f_dentry->d_inode, name, len, O_RDWR, opc, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); itp->it_flags |= MDS_OPEN_BY_FID; rc = md_intent_lock(sbi->ll_md_exp, op_data, lmm, lmmsize, itp, @@ -422,7 +414,7 @@ out: it_clear_disposition(itp, DISP_ENQ_COMPLETE); ll_intent_drop_lock(itp); - RETURN(rc); + return rc; } /** @@ -464,7 +456,6 @@ int ll_local_open(struct file *file, struct lookup_intent *it, { struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; LASSERT(!LUSTRE_FPRIVATE(file)); @@ -477,7 +468,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, lli, it, och); if (rc) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if ((it->it_flags & FMODE_WRITE) && @@ -489,7 +480,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, LUSTRE_FPRIVATE(file) = fd; ll_readahead_init(inode, &fd->fd_ras); fd->fd_omode = it->it_flags; - RETURN(0); + return 0; } /* Open a file, and (for the very first open) create objects on the OSTs at @@ -514,7 +505,6 @@ int ll_file_open(struct inode *inode, struct file *file) __u64 *och_usecount = NULL; struct ll_file_data *fd; int rc = 0, opendir_set = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); @@ -524,7 +514,7 @@ int ll_file_open(struct inode *inode, struct file *file) fd = ll_file_data_get(); if (fd == NULL) - GOTO(out_och_free, rc = -ENOMEM); + GOTO(out_openerr, rc = -ENOMEM); fd->fd_file = file; if (S_ISDIR(inode->i_mode)) { @@ -540,7 +530,7 @@ int ll_file_open(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = fd; - RETURN(0); + return 0; } if (!it || !it->d.lustre.it_disposition) { @@ -700,8 +690,6 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, struct obd_info oinfo = { { { 0 } } }; int rc; - ENTRY; - LASSERT(lsm != NULL); oinfo.oi_md = lsm; @@ -736,7 +724,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLDATAVERSION); - RETURN(rc); + return rc; } /** @@ -749,7 +737,6 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, struct obd_capa *capa = ll_mdscapa_get(inode); struct lov_stripe_md *lsm; int rc; - ENTRY; lsm = ccc_inode_lsm_get(inode); rc = ll_lsm_getattr(lsm, ll_i2dtexp(inode), @@ -765,7 +752,7 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, (unsigned long)ll_inode_blksize(inode)); } ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_merge_lvb(const struct lu_env *env, struct inode *inode) @@ -776,8 +763,6 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) struct ost_lvb lvb; int rc = 0; - ENTRY; - ll_inode_size_lock(inode); /* merge timestamps the most recently obtained from mds with timestamps obtained from osts */ @@ -810,7 +795,7 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) } ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm, @@ -860,7 +845,6 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct cl_io *io; ssize_t result; - ENTRY; restart: io = ccc_env_thread_io(env); @@ -986,15 +970,14 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -1004,7 +987,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_READ, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_read(struct file *file, char *buf, size_t count, @@ -1015,11 +998,10 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1033,7 +1015,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } /* @@ -1047,15 +1029,14 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -1065,7 +1046,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_WRITE, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, @@ -1076,11 +1057,10 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1094,7 +1074,7 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } @@ -1110,11 +1090,10 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, struct vvp_io_args *args; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_SPLICE); args->u.splice.via_pipe = pipe; @@ -1122,7 +1101,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, result = ll_file_io_generic(env, args, in_file, CIT_READ, ppos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, @@ -1134,14 +1113,13 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, int lsm_size; int rc = 0; struct lov_stripe_md *lsm = NULL, *lsm2; - ENTRY; OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) + if (!lsm_has_objects(lsm)) GOTO(out, rc = -ENOENT); lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) * @@ -1175,18 +1153,17 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) { struct ll_recreate_obj ucreat; struct ost_id oi; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, sizeof(ucreat))) - RETURN(-EFAULT); + return -EFAULT; ostid_set_seq_mdt0(&oi); ostid_set_id(&oi, ucreat.lrc_id); - RETURN(ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx)); + return ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx); } static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) @@ -1194,17 +1171,16 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) struct lu_fid fid; struct ost_id oi; obd_count ost_idx; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) - RETURN(-EFAULT); + return -EFAULT; fid_to_ostid(&fid, &oi); ost_idx = (fid_seq(&fid) >> 16) & 0xffff; - RETURN(ll_lov_recreate(inode, &oi, ost_idx)); + return ll_lov_recreate(inode, &oi, ost_idx); } int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, @@ -1213,14 +1189,13 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, struct lov_stripe_md *lsm = NULL; struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; int rc = 0; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) { ccc_inode_lsm_put(inode, lsm); CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", inode->i_ino); - RETURN(-EEXIST); + return -EEXIST; } ll_inode_size_lock(inode); @@ -1237,7 +1212,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ll_inode_size_unlock(inode); ll_intent_release(&oit); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; out_req_free: ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); goto out; @@ -1256,13 +1231,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, filename, strlen(filename), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); @@ -1297,6 +1272,12 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, * passing it to userspace. */ if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) { + int stripe_count; + + stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + stripe_count = 0; + /* if function called for directory - we should * avoid swab not existent lsm objects */ if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) { @@ -1304,13 +1285,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v1 *)lmm)->lmm_objects, - ((struct lov_user_md_v1 *)lmm)->lmm_stripe_count); + stripe_count); } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) { lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm); if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v3 *)lmm)->lmm_objects, - ((struct lov_user_md_v3 *)lmm)->lmm_stripe_count); + stripe_count); } } @@ -1329,24 +1310,23 @@ static int ll_lov_setea(struct inode *inode, struct file *file, int lum_size = sizeof(struct lov_user_md) + sizeof(struct lov_user_ost_data); int rc; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_LARGE(lump, lum_size); if (lump == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { OBD_FREE_LARGE(lump, lum_size); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size); OBD_FREE_LARGE(lump, lum_size); - RETURN(rc); + return rc; } static int ll_lov_setstripe(struct inode *inode, struct file *file, @@ -1358,17 +1338,16 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; int lum_size, rc; int flags = FMODE_WRITE; - ENTRY; /* first try with v1 which is smaller than v3 */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(lumv1, lumv1p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) { lum_size = sizeof(struct lov_user_md_v3); if (copy_from_user(&lumv3, lumv3p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lumv1, lum_size); @@ -1384,21 +1363,20 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); } - RETURN(rc); + return rc; } static int ll_lov_getstripe(struct inode *inode, unsigned long arg) { struct lov_stripe_md *lsm; int rc = -ENODATA; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1407,17 +1385,16 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; int rc; - ENTRY; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { CWARN("group lock already existed with gid %lu\n", fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock == NULL); spin_unlock(&lli->lli_lock); @@ -1425,14 +1402,14 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) rc = cl_get_grouplock(cl_i2info(inode)->lli_clob, arg, (file->f_flags & O_NONBLOCK), &grouplock); if (rc) - RETURN(rc); + return rc; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { spin_unlock(&lli->lli_lock); CERROR("another thread just won the race\n"); cl_put_grouplock(&grouplock); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= LL_FILE_GROUP_LOCKED; @@ -1440,7 +1417,7 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) spin_unlock(&lli->lli_lock); CDEBUG(D_INFO, "group lock %lu obtained\n", arg); - RETURN(0); + return 0; } int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1448,13 +1425,12 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; - ENTRY; spin_lock(&lli->lli_lock); if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) { spin_unlock(&lli->lli_lock); CWARN("no group lock held\n"); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock != NULL); @@ -1462,7 +1438,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) CWARN("group lock %lu doesn't match current id %lu\n", arg, fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } grouplock = fd->fd_grouplock; @@ -1472,7 +1448,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) cl_put_grouplock(&grouplock); CDEBUG(D_INFO, "group lock %lu released\n", arg); - RETURN(0); + return 0; } /** @@ -1489,17 +1465,16 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) struct inode *inode = dentry->d_inode; struct obd_client_handle *och; int rc; - ENTRY; LASSERT(inode); /* Root ? Do nothing. */ if (dentry->d_inode->i_sb->s_root == dentry) - RETURN(0); + return 0; /* No open handle to close? Move away */ if (!it_disposition(it, DISP_OPEN_OPEN)) - RETURN(0); + return 0; LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0); @@ -1518,7 +1493,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) ptlrpc_req_finished(it->d.lustre.it_data); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } - RETURN(rc); + return rc; } /** @@ -1533,7 +1508,6 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, struct ll_fiemap_info_key fm_key = { .name = KEY_FIEMAP, }; int vallen = num_bytes; int rc; - ENTRY; /* Checks for fiemap flags */ if (fiemap->fm_flags & ~LUSTRE_FIEMAP_FLAGS_COMPAT) { @@ -1579,7 +1553,7 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, out: ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_fid2path(struct inode *inode, void *arg) @@ -1587,26 +1561,25 @@ int ll_fid2path(struct inode *inode, void *arg) struct obd_export *exp = ll_i2mdexp(inode); struct getinfo_fid2path *gfout, *gfin; int outsize, rc; - ENTRY; if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) - RETURN(-EPERM); + return -EPERM; /* Need to get the buflen */ OBD_ALLOC_PTR(gfin); if (gfin == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(gfin, arg, sizeof(*gfin))) { OBD_FREE_PTR(gfin); - RETURN(-EFAULT); + return -EFAULT; } outsize = sizeof(*gfout) + gfin->gf_pathlen; OBD_ALLOC(gfout, outsize); if (gfout == NULL) { OBD_FREE_PTR(gfin); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(gfout, gfin, sizeof(*gfout)); OBD_FREE_PTR(gfin); @@ -1621,7 +1594,7 @@ int ll_fid2path(struct inode *inode, void *arg) gf_free: OBD_FREE(gfout, outsize); - RETURN(rc); + return rc; } static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) @@ -1635,13 +1608,13 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) * required fiemap buffer */ if (get_user(extent_count, &((struct ll_user_fiemap __user *)arg)->fm_extent_count)) - RETURN(-EFAULT); + return -EFAULT; num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); OBD_ALLOC_LARGE(fiemap_s, num_bytes); if (fiemap_s == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* get the fiemap value */ if (copy_from_user(fiemap_s, (struct ll_user_fiemap __user *)arg, @@ -1673,7 +1646,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) error: OBD_FREE_LARGE(fiemap_s, num_bytes); - RETURN(rc); + return rc; } /* @@ -1692,24 +1665,21 @@ int ll_data_version(struct inode *inode, __u64 *data_version, struct ll_sb_info *sbi = ll_i2sbi(inode); struct obdo *obdo = NULL; int rc; - ENTRY; /* If no stripe, we consider version is 0. */ lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) { + if (!lsm_has_objects(lsm)) { *data_version = 0; CDEBUG(D_INODE, "No object for inode\n"); - RETURN(0); + GOTO(out, rc = 0); } OBD_ALLOC_PTR(obdo); - if (obdo == NULL) { - ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); - } + if (obdo == NULL) + GOTO(out, rc = -ENOMEM); rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, obdo, 0, extent_lock); - if (!rc) { + if (rc == 0) { if (!(obdo->o_valid & OBD_MD_FLDATAVERSION)) rc = -EOPNOTSUPP; else @@ -1717,9 +1687,9 @@ int ll_data_version(struct inode *inode, __u64 *data_version, } OBD_FREE_PTR(obdo); +out: ccc_inode_lsm_put(inode, lsm); - - RETURN(rc); + return rc; } struct ll_swap_stack { @@ -1741,7 +1711,7 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, OBD_ALLOC_PTR(llss); if (llss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; llss->inode1 = file1->f_dentry->d_inode; llss->inode2 = file2->f_dentry->d_inode; @@ -1749,8 +1719,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, if (!S_ISREG(llss->inode2->i_mode)) GOTO(free, rc = -EINVAL); - if (ll_permission(llss->inode1, MAY_WRITE, NULL) || - ll_permission(llss->inode2, MAY_WRITE, NULL)) + if (inode_permission(llss->inode1, MAY_WRITE) || + inode_permission(llss->inode2, MAY_WRITE)) GOTO(free, rc = -EPERM); if (llss->inode2->i_sb != llss->inode1->i_sb) @@ -1830,12 +1800,12 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, rc = -ENOMEM; op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0, 0, LUSTRE_OPC_ANY, &msl); - if (op_data != NULL) { - rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, - ll_i2mdexp(llss->inode1), - sizeof(*op_data), op_data, NULL); - ll_finish_md_op_data(op_data); - } + if (IS_ERR(op_data)) + GOTO(free, rc = PTR_ERR(op_data)); + + rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, ll_i2mdexp(llss->inode1), + sizeof(*op_data), op_data, NULL); + ll_finish_md_op_data(op_data); putgl: if (gid != 0) { @@ -1880,7 +1850,7 @@ free: if (llss != NULL) OBD_FREE_PTR(llss); - RETURN(rc); + return rc; } long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -1888,7 +1858,6 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct inode *inode = file->f_dentry->d_inode; struct ll_file_data *fd = LUSTRE_FPRIVATE(file); int flags, rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),cmd=%x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -1896,7 +1865,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* asm-ppc{,64} declares TCGETS, et. al. as type 't' not 'T' */ if (_IOC_TYPE(cmd) == 'T' || _IOC_TYPE(cmd) == 't') /* tty ioctls */ - RETURN(-ENOTTY); + return -ENOTTY; switch(cmd) { case LL_IOC_GETFLAGS: @@ -1909,66 +1878,66 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * not abused, and to handle any flag side effects. */ if (get_user(flags, (int *) arg)) - RETURN(-EFAULT); + return -EFAULT; if (cmd == LL_IOC_SETFLAGS) { if ((flags & LL_FILE_IGNORE_LOCK) && !(file->f_flags & O_DIRECT)) { CERROR("%s: unable to disable locking on " "non-O_DIRECT file\n", current->comm); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= flags; } else { fd->fd_flags &= ~flags; } - RETURN(0); + return 0; case LL_IOC_LOV_SETSTRIPE: - RETURN(ll_lov_setstripe(inode, file, arg)); + return ll_lov_setstripe(inode, file, arg); case LL_IOC_LOV_SETEA: - RETURN(ll_lov_setea(inode, file, arg)); + return ll_lov_setea(inode, file, arg); case LL_IOC_LOV_SWAP_LAYOUTS: { struct file *file2; struct lustre_swap_layouts lsl; if (copy_from_user(&lsl, (char *)arg, sizeof(struct lustre_swap_layouts))) - RETURN(-EFAULT); + return -EFAULT; if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */ - RETURN(-EPERM); + return -EPERM; file2 = fget(lsl.sl_fd); if (file2 == NULL) - RETURN(-EBADF); + return -EBADF; rc = -EPERM; if ((file2->f_flags & O_ACCMODE) != 0) /* O_WRONLY or O_RDWR */ rc = ll_swap_layouts(file, file2, &lsl); fput(file2); - RETURN(rc); + return rc; } case LL_IOC_LOV_GETSTRIPE: - RETURN(ll_lov_getstripe(inode, arg)); + return ll_lov_getstripe(inode, arg); case LL_IOC_RECREATE_OBJ: - RETURN(ll_lov_recreate_obj(inode, arg)); + return ll_lov_recreate_obj(inode, arg); case LL_IOC_RECREATE_FID: - RETURN(ll_lov_recreate_fid(inode, arg)); + return ll_lov_recreate_fid(inode, arg); case FSFILT_IOC_FIEMAP: - RETURN(ll_ioctl_fiemap(inode, arg)); + return ll_ioctl_fiemap(inode, arg); case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); case LL_IOC_GROUP_LOCK: - RETURN(ll_get_grouplock(inode, file, arg)); + return ll_get_grouplock(inode, file, arg); case LL_IOC_GROUP_UNLOCK: - RETURN(ll_put_grouplock(inode, file, arg)); + return ll_put_grouplock(inode, file, arg); case IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly @@ -1977,30 +1946,30 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case FSFILT_IOC_SETVERSION: */ case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); case LL_IOC_PATH2FID: { if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_DATA_VERSION: { struct ioc_data_version idv; int rc; if (copy_from_user(&idv, (char *)arg, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; rc = ll_data_version(inode, &idv.idv_version, !(idv.idv_flags & LL_DV_NOFLUSH)); if (rc == 0 && copy_to_user((char *) arg, &idv, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(rc); + return rc; } case LL_IOC_GET_MDTIDX: { @@ -2008,16 +1977,16 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_HSM_STATE_GET: { struct md_op_data *op_data; struct hsm_user_state *hus; @@ -2025,13 +1994,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hus); if (hus == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hus); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2042,7 +2011,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hus); - RETURN(rc); + return rc; } case LL_IOC_HSM_STATE_SET: { struct md_op_data *op_data; @@ -2051,10 +2020,10 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hss); if (hss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { OBD_FREE_PTR(hss); - RETURN(-EFAULT); + return -EFAULT; } /* Non-root users are forbidden to set or clear flags which are @@ -2062,14 +2031,14 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && !cfs_capable(CFS_CAP_SYS_ADMIN)) { OBD_FREE_PTR(hss); - RETURN(-EPERM); + return -EPERM; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hss); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hss); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2078,7 +2047,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hss); - RETURN(rc); + return rc; } case LL_IOC_HSM_ACTION: { struct md_op_data *op_data; @@ -2087,13 +2056,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hca); if (hca == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hca); - RETURN(-ENOMEM); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2104,17 +2073,17 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hca); - RETURN(rc); + return rc; } default: { int err; if (LLIOC_STOP == ll_iocontrol_call(inode, file, cmd, arg, &err)) - RETURN(err); + return err; - RETURN(obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, + (void *)arg); } } } @@ -2125,7 +2094,6 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) struct inode *inode = file->f_dentry->d_inode; loff_t retval, eof = 0; - ENTRY; retval = offset + ((origin == SEEK_END) ? i_size_read(inode) : (origin == SEEK_CUR) ? file->f_pos : 0); CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%llu=%#llx(%d)\n", @@ -2136,13 +2104,13 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) if (origin == SEEK_END || origin == SEEK_HOLE || origin == SEEK_DATA) { retval = ll_glimpse_size(inode); if (retval != 0) - RETURN(retval); + return retval; eof = i_size_read(inode); } - retval = ll_generic_file_llseek_size(file, offset, origin, + retval = generic_file_llseek_size(file, offset, origin, ll_file_maxbytes(inode), eof); - RETURN(retval); + return retval; } int ll_flush(struct file *file, fl_owner_t id) @@ -2184,15 +2152,14 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, struct obd_capa *capa = NULL; struct cl_fsync_io *fio; int result; - ENTRY; if (mode != CL_FSYNC_NONE && mode != CL_FSYNC_LOCAL && mode != CL_FSYNC_DISCARD && mode != CL_FSYNC_ALL) - RETURN(-EINVAL); + return -EINVAL; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE); @@ -2220,7 +2187,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, capa_put(capa); - RETURN(result); + return result; } /* @@ -2237,7 +2204,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) struct ptlrpc_request *req; struct obd_capa *oc; int rc, err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -2281,23 +2247,24 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) } mutex_unlock(&inode->i_mutex); - RETURN(rc); + return rc; } int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) { struct inode *inode = file->f_dentry->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_FLOCK, - .ei_cb_cp =ldlm_flock_completion_ast, - .ei_cbdata = file_lock }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_FLOCK, + .ei_cb_cp = ldlm_flock_completion_ast, + .ei_cbdata = file_lock, + }; struct md_op_data *op_data; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock = {{0}}; int flags = 0; int rc; int rc2 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n", inode->i_ino, file_lock); @@ -2315,7 +2282,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) flock.l_flock.start = file_lock->fl_start; flock.l_flock.end = file_lock->fl_end; } else { - RETURN(-EINVAL); + return -EINVAL; } flock.l_flock.pid = file_lock->fl_pid; @@ -2350,7 +2317,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) default: CDEBUG(D_INFO, "Unknown fcntl lock type: %d\n", file_lock->fl_type); - RETURN (-ENOTSUPP); + return -ENOTSUPP; } switch (cmd) { @@ -2377,13 +2344,13 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) break; default: CERROR("unknown fcntl lock command: %d\n", cmd); - RETURN (-EINVAL); + return -EINVAL; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); CDEBUG(D_DLMTRACE, "inode=%lu, pid=%u, flags=%#x, mode=%u, " "start="LPU64", end="LPU64"\n", inode->i_ino, flock.l_flock.pid, @@ -2409,14 +2376,12 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) ll_finish_md_op_data(op_data); - RETURN(rc); + return rc; } int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) { - ENTRY; - - RETURN(-ENOSYS); + return -ENOSYS; } /** @@ -2438,17 +2403,16 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) struct lu_fid *fid; __u64 flags; int i; - ENTRY; if (!inode) - RETURN(0); + return 0; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid), ldlm_lockname[mode]); flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; - for (i = 0; i < MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { + for (i = 0; i <= MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { policy.l_inodebits.bits = *bits & (1 << i); if (policy.l_inodebits.bits == 0) continue; @@ -2467,7 +2431,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) } } } - RETURN(*bits == 0); + return *bits == 0; } ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, @@ -2476,7 +2440,6 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, ldlm_policy_data_t policy = { .l_inodebits = {bits}}; struct lu_fid *fid; ldlm_mode_t rc; - ENTRY; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); @@ -2484,7 +2447,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, rc = md_lock_match(ll_i2mdexp(inode), LDLM_FL_BLOCK_GRANTED|flags, fid, LDLM_IBITS, &policy, LCK_CR|LCK_CW|LCK_PR|LCK_PW, lockh); - RETURN(rc); + return rc; } static int ll_inode_revalidate_fini(struct inode *inode, int rc) @@ -2513,7 +2476,6 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, struct ptlrpc_request *req = NULL; struct obd_export *exp; int rc = 0; - ENTRY; LASSERT(inode != NULL); @@ -2537,7 +2499,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, dentry->d_inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); oit.it_create_mode |= M_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, @@ -2575,7 +2537,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, if (S_ISREG(inode->i_mode)) { rc = ll_get_max_mdsize(sbi, &ealen); if (rc) - RETURN(rc); + return rc; valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE; } @@ -2583,7 +2545,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, 0, ealen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = valid; /* Once OBD_CONNECT_ATTRFID is not supported, we can't find one @@ -2593,7 +2555,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, ll_finish_md_op_data(op_data); if (rc) { rc = ll_inode_revalidate_fini(inode, rc); - RETURN(rc); + return rc; } rc = ll_prep_inode(&inode, req, NULL, NULL); @@ -2608,11 +2570,10 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, { struct inode *inode = dentry->d_inode; int rc; - ENTRY; rc = __ll_inode_revalidate_it(dentry, it, ibits); if (rc != 0) - RETURN(rc); + return rc; /* if object isn't regular file, don't validate size */ if (!S_ISREG(inode->i_mode)) { @@ -2622,7 +2583,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, } else { rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, @@ -2672,21 +2633,19 @@ struct posix_acl * ll_get_acl(struct inode *inode, int type) { struct ll_inode_info *lli = ll_i2info(inode); struct posix_acl *acl = NULL; - ENTRY; spin_lock(&lli->lli_lock); /* VFS' acl_permission_check->check_acl will release the refcount */ acl = posix_acl_dup(lli->lli_posix_acl); spin_unlock(&lli->lli_lock); - RETURN(acl); + return acl; } int ll_inode_permission(struct inode *inode, int mask) { int rc = 0; - ENTRY; #ifdef MAY_NOT_BLOCK if (mask & MAY_NOT_BLOCK) @@ -2702,7 +2661,7 @@ int ll_inode_permission(struct inode *inode, int mask) rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(rc); + return rc; } CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), inode mode %x mask %o\n", @@ -2712,9 +2671,9 @@ int ll_inode_permission(struct inode *inode, int mask) return lustre_check_remote_perm(inode, mask); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); - rc = ll_generic_permission(inode, mask, flags, ll_check_acl); + rc = generic_permission(inode, mask); - RETURN(rc); + return rc; } #define READ_METHOD aio_read @@ -2806,16 +2765,15 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) { unsigned int size; struct llioc_data *in_data = NULL; - ENTRY; if (cb == NULL || cmd == NULL || count > LLIOC_MAX_CMD || count < 0) - RETURN(NULL); + return NULL; size = sizeof(*in_data) + count * sizeof(unsigned int); OBD_ALLOC(in_data, size); if (in_data == NULL) - RETURN(NULL); + return NULL; memset(in_data, 0, sizeof(*in_data)); in_data->iocd_size = size; @@ -2827,7 +2785,7 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) list_add_tail(&in_data->iocd_list, &llioc.ioc_head); up_write(&llioc.ioc_sem); - RETURN(in_data); + return in_data; } void ll_iocontrol_unregister(void *magic) @@ -2890,14 +2848,13 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) struct cl_env_nest nest; struct lu_env *env; int result; - ENTRY; if (lli->lli_clob == NULL) - RETURN(0); + return 0; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); result = cl_conf_set(env, lli->lli_clob, conf); cl_env_nested_put(&nest, env); @@ -2915,7 +2872,7 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) ldlm_lock_allow_match(lock); } } - RETURN(result); + return result; } /* Fetch layout from MDT with getxattr request, if it's not ready yet */ @@ -2930,10 +2887,13 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) void *lmm; int lmmsize; int rc; - ENTRY; - if (lock->l_lvb_data != NULL) - RETURN(0); + CDEBUG(D_INODE, DFID" LVB_READY=%d l_lvb_data=%p l_lvb_len=%d\n", + PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY), + lock->l_lvb_data, lock->l_lvb_len); + + if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY)) + return 0; /* if layout lock was granted right away, the layout is returned * within DLM_LVB of dlm reply; otherwise if the lock was ever @@ -2948,7 +2908,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lmmsize, 0, &req); capa_put(oc); if (rc < 0) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (body == NULL || body->eadatasize > lmmsize) @@ -2968,16 +2928,12 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); - if (lock->l_lvb_data == NULL) { - lock->l_lvb_data = lvbdata; - lock->l_lvb_len = lmmsize; - lvbdata = NULL; - } - unlock_res_and_lock(lock); + if (lock->l_lvb_data != NULL) + OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len); - if (lvbdata != NULL) - OBD_FREE_LARGE(lvbdata, lmmsize); - EXIT; + lock->l_lvb_data = lvbdata; + lock->l_lvb_len = lmmsize; + unlock_res_and_lock(lock); out: ptlrpc_req_finished(req); @@ -2999,7 +2955,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, int rc = 0; bool lvb_ready; bool wait_layout = false; - ENTRY; LASSERT(lustre_handle_is_used(lockh)); @@ -3008,7 +2963,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, LASSERT(ldlm_has_layout(lock)); LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n", - inode, PFID(&lli->lli_fid), reconf); + inode, PFID(&lli->lli_fid), reconf); /* in case this is a caching lock and reinstate with new inode */ md_set_lock_data(sbi->ll_md_exp, &lockh->cookie, inode, NULL); @@ -3068,7 +3023,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, /* refresh layout failed, need to wait */ wait_layout = rc == -EBUSY; - EXIT; out: LDLM_LOCK_PUT(lock); @@ -3090,7 +3044,7 @@ out: CDEBUG(D_INODE, "file: "DFID" waiting layout return: %d.\n", PFID(&lli->lli_fid), rc); } - RETURN(rc); + return rc; } /** @@ -3114,17 +3068,17 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) struct lookup_intent it; struct lustre_handle lockh; ldlm_mode_t mode; - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS, - .ei_mode = LCK_CR, - .ei_cb_bl = ll_md_blocking_ast, - .ei_cb_cp = ldlm_completion_ast, - .ei_cbdata = NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = LCK_CR, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; int rc; - ENTRY; *gen = lli->lli_layout_gen; if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) - RETURN(0); + return 0; /* sanity checks */ LASSERT(fid_is_sane(ll_inode2fid(inode))); @@ -3136,7 +3090,7 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) if (mode != 0) { /* hit cached lock */ rc = ll_layout_lock_set(&lockh, mode, inode, gen, false); if (rc == 0) - RETURN(0); + return 0; /* better hold lli_layout_mutex to try again otherwise * it will have starvation problem. */ @@ -3154,14 +3108,14 @@ again: goto again; mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } op_data = ll_prep_md_op_data(NULL, inode, inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { mutex_unlock(&lli->lli_layout_mutex); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } /* have to enqueue one */ @@ -3194,5 +3148,5 @@ again: } mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index b6fd9593325a..edd512b20ee3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -41,7 +41,6 @@ #define DEBUG_SUBSYSTEM S_LLITE #include <linux/fs.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/file.h> #include <linux/kmod.h> @@ -171,7 +170,6 @@ static int capa_thread_main(void *unused) struct inode *inode = NULL; struct l_wait_info lwi = { 0 }; int rc; - ENTRY; thread_set_flags(&ll_capa_thread, SVC_RUNNING); wake_up(&ll_capa_thread.t_ctl_waitq); @@ -281,7 +279,7 @@ static int capa_thread_main(void *unused) thread_set_flags(&ll_capa_thread, SVC_STOPPED); wake_up(&ll_capa_thread.t_ctl_waitq); - RETURN(0); + return 0; } void ll_capa_timer_callback(unsigned long unused) @@ -291,8 +289,7 @@ void ll_capa_timer_callback(unsigned long unused) int ll_capa_thread_start(void) { - task_t *task; - ENTRY; + struct task_struct *task; init_waitqueue_head(&ll_capa_thread.t_ctl_waitq); @@ -300,12 +297,12 @@ int ll_capa_thread_start(void) if (IS_ERR(task)) { CERROR("cannot start expired capa thread: rc %ld\n", PTR_ERR(task)); - RETURN(PTR_ERR(task)); + return PTR_ERR(task); } wait_event(ll_capa_thread.t_ctl_waitq, thread_is_running(&ll_capa_thread)); - RETURN(0); + return 0; } void ll_capa_thread_stop(void) @@ -322,10 +319,8 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) struct obd_capa *ocapa; int found = 0; - ENTRY; - if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0) - RETURN(NULL); + return NULL; LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW || opc == CAPA_OPC_OSS_TRUNC); @@ -369,7 +364,7 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) } spin_unlock(&capa_lock); - RETURN(ocapa); + return ocapa; } EXPORT_SYMBOL(ll_osscapa_get); @@ -377,12 +372,11 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct obd_capa *ocapa; - ENTRY; LASSERT(inode != NULL); if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0) - RETURN(NULL); + return NULL; spin_lock(&capa_lock); ocapa = capa_get(lli->lli_mds_capa); @@ -392,7 +386,7 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) atomic_set(&ll_capa_debug, 0); } - RETURN(ocapa); + return ocapa; } static struct obd_capa *do_add_mds_capa(struct inode *inode, @@ -525,7 +519,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) { struct inode *inode = ocapa->u.cli.inode; int rc = 0; - ENTRY; LASSERT(ocapa); @@ -561,7 +554,7 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) capa_put(ocapa); iput(inode); - RETURN(rc); + return rc; } spin_lock(&ocapa->c_lock); @@ -575,7 +568,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) if (capa_for_oss(capa)) inode_add_oss_capa(inode, ocapa); DEBUG_CAPA(D_SEC, capa, "renew"); - EXIT; retry: list_del_init(&ocapa->c_list); sort_add_capa(ocapa, ll_capa_list); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 00b2b38d4c97..1f5825c87a79 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -50,14 +50,12 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page) { struct ll_inode_info *lli = ll_i2info(club->cob_inode); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_SOM_DIRTY; if (page != NULL && list_empty(&page->cpg_pending_linkage)) list_add(&page->cpg_pending_linkage, &club->cob_pending_list); spin_unlock(&lli->lli_lock); - EXIT; } /** records that a write has completed */ @@ -66,7 +64,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) struct ll_inode_info *lli = ll_i2info(club->cob_inode); int rc = 0; - ENTRY; spin_lock(&lli->lli_lock); if (page != NULL && !list_empty(&page->cpg_pending_linkage)) { list_del_init(&page->cpg_pending_linkage); @@ -75,7 +72,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) spin_unlock(&lli->lli_lock); if (rc) ll_queue_done_writing(club->cob_inode, 0); - EXIT; } /** Queues DONE_WRITING if @@ -85,7 +81,6 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= flags; @@ -119,14 +114,12 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) spin_unlock(&lcq->lcq_lock); } spin_unlock(&lli->lli_lock); - EXIT; } /** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) { struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; op_data->op_flags |= MF_SOM_CHANGE; /* Check if Size-on-MDS attributes are valid. */ @@ -140,7 +133,6 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) op_data->op_attr.ia_valid |= ATTR_MTIME_SET | ATTR_CTIME_SET | ATTR_ATIME_SET | ATTR_SIZE | ATTR_BLOCKS; } - EXIT; } /** Closes ioepoch and packs Size-on-MDS attribute if needed into @op_data. */ @@ -149,7 +141,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); if (!(list_empty(&club->cob_pending_list))) { @@ -209,7 +200,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, spin_unlock(&lli->lli_lock); ll_done_writing_attr(inode, op_data); - EXIT; out: return; } @@ -225,7 +215,6 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) __u32 old_flags; struct obdo *oa; int rc; - ENTRY; LASSERT(op_data != NULL); if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) @@ -236,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) OBDO_ALLOC(oa); if (!oa) { CERROR("can't allocate memory for Size-on-MDS update.\n"); - RETURN(-ENOMEM); + return -ENOMEM; } old_flags = op_data->op_flags; @@ -266,7 +255,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) ptlrpc_req_finished(request); OBDO_FREE(oa); - RETURN(rc); + return rc; } /** @@ -293,14 +282,12 @@ static void ll_done_writing(struct inode *inode) struct obd_client_handle *och = NULL; struct md_op_data *op_data; int rc; - ENTRY; LASSERT(exp_connect_som(ll_i2mdexp(inode))); OBD_ALLOC_PTR(op_data); if (op_data == NULL) { CERROR("can't allocate op_data\n"); - EXIT; return; } @@ -324,7 +311,6 @@ out: md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och); OBD_FREE_PTR(och); } - EXIT; } static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) @@ -347,7 +333,6 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) static int ll_close_thread(void *arg) { struct ll_close_queue *lcq = arg; - ENTRY; complete(&lcq->lcq_comp); @@ -371,13 +356,13 @@ static int ll_close_thread(void *arg) CDEBUG(D_INFO, "ll_close exiting\n"); complete(&lcq->lcq_comp); - RETURN(0); + return 0; } int ll_close_thread_start(struct ll_close_queue **lcq_ret) { struct ll_close_queue *lcq; - task_t *task; + struct task_struct *task; if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD)) return -EINTR; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5227c5c4ebe2..47e443d90fe1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -90,6 +90,7 @@ extern struct file_operations ll_pgcache_seq_fops; #define REMOTE_PERM_HASHSIZE 16 struct ll_getname_data { + struct dir_context ctx; char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ struct lu_fid lgd_fid; /* target fid we are looking for */ int lgd_found; /* inode matched? */ @@ -438,14 +439,6 @@ struct rmtacl_ctl_table { #define EE_HASHES 32 -struct eacl_entry { - struct list_head ee_list; - pid_t ee_key; /* hash key */ - struct lu_fid ee_fid; - int ee_type; /* ACL type for ACCESS or DEFAULT */ - ext_acl_xattr_header *ee_acl; -}; - struct eacl_table { spinlock_t et_lock; struct list_head et_entries[EE_HASHES]; @@ -512,6 +505,7 @@ struct ll_sb_info { * clustred nfs */ struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; + __kernel_fsid_t ll_fsid; }; #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) @@ -687,8 +681,7 @@ extern struct file_operations ll_dir_operations; extern struct inode_operations ll_dir_inode_operations; struct page *ll_get_dir_page(struct inode *dir, __u64 hash, struct ll_dir_chain *chain); -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir); +int ll_dir_read(struct inode *inode, struct dir_context *ctx); int ll_get_mdt_idx(struct inode *inode); /* llite/namei.c */ @@ -792,8 +785,7 @@ void ll_intent_release(struct lookup_intent *); void ll_invalidate_aliases(struct inode *); void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft); void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry); -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *d_name); int ll_revalidate_it_finish(struct ptlrpc_request *request, struct lookup_intent *it, struct dentry *de); @@ -842,6 +834,7 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen); /* llite/llite_nfs.c */ extern struct export_operations lustre_export_operations; __u32 get_uuid2int(const char *name, int len); +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid); struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid); @@ -1129,7 +1122,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); int lustre_check_remote_perm(struct inode *inode, int mask); /* llite/llite_capa.c */ -extern timer_list_t ll_capa_timer; +extern struct timer_list ll_capa_timer; int ll_capa_thread_start(void); void ll_capa_thread_stop(void); @@ -1168,6 +1161,14 @@ void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which); /* llite/llite_rmtacl.c */ #ifdef CONFIG_FS_POSIX_ACL +struct eacl_entry { + struct list_head ee_list; + pid_t ee_key; /* hash key */ + struct lu_fid ee_fid; + int ee_type; /* ACL type for ACCESS or DEFAULT */ + ext_acl_xattr_header *ee_acl; +}; + obd_valid rce_ops2valid(int ops); struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key); int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops); @@ -1183,6 +1184,11 @@ struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, void et_search_free(struct eacl_table *et, pid_t key); void et_init(struct eacl_table *et); void et_fini(struct eacl_table *et); +#else +static inline obd_valid rce_ops2valid(int ops) +{ + return 0; +} #endif /* statahead.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index afae8010623d..b868c2bd58d2 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -42,7 +42,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <linux/mm.h> #include <lustre_lite.h> @@ -79,11 +78,10 @@ static struct ll_sb_info *ll_init_sbi(void) struct sysinfo si; class_uuid_t uuid; int i; - ENTRY; OBD_ALLOC(sbi, sizeof(*sbi)); if (!sbi) - RETURN(NULL); + return NULL; spin_lock_init(&sbi->ll_lock); mutex_init(&sbi->ll_lco.lco_lock); @@ -141,13 +139,12 @@ static struct ll_sb_info *ll_init_sbi(void) atomic_set(&sbi->ll_agl_total, 0); sbi->ll_flags |= LL_SBI_AGL_ENABLED; - RETURN(sbi); + return sbi; } void ll_free_sbi(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; if (sbi != NULL) { spin_lock(&ll_sb_lock); @@ -155,7 +152,6 @@ void ll_free_sbi(struct super_block *sb) spin_unlock(&ll_sb_lock); OBD_FREE(sbi, sizeof(*sbi)); } - EXIT; } static struct dentry_operations ll_d_root_ops = { @@ -178,22 +174,21 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct lustre_md lmd; obd_valid valid; int size, err, checksum; - ENTRY; obd = class_name2obd(md); if (!obd) { CERROR("MD %s: not setup or attached\n", md); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC_PTR(data); if (data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(osfs); if (osfs == NULL) { OBD_FREE_PTR(data); - RETURN(-ENOMEM); + return -ENOMEM; } if (proc_lustre_fs_root) { @@ -583,15 +578,17 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* s_dev is also used in lt_compare() to compare two fs, but that is * only a node-local comparison. */ uuid = obd_get_uuid(sbi->ll_md_exp); - if (uuid != NULL) + if (uuid != NULL) { sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid)); + get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); + } if (data != NULL) OBD_FREE_PTR(data); if (osfs != NULL) OBD_FREE_PTR(osfs); - RETURN(err); + return err; out_root: if (root) iput(root); @@ -627,7 +624,7 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize) if (rc) CERROR("Get max mdsize error rc %d \n", rc); - RETURN(rc); + return rc; } void ll_dump_inode(struct inode *inode) @@ -676,7 +673,6 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { @@ -703,16 +699,12 @@ void client_common_put_super(struct super_block *sb) obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; - - EXIT; } void ll_kill_super(struct super_block *sb) { struct ll_sb_info *sbi; - ENTRY; - /* not init sb ?*/ if (!(sb->s_flags & MS_ACTIVE)) return; @@ -725,31 +717,29 @@ void ll_kill_super(struct super_block *sb) sb->s_dev = sbi->ll_sdev_orig; sbi->ll_umounting = 1; } - EXIT; } char *ll_read_opt(const char *opt, char *data) { char *value; char *retval; - ENTRY; CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); if (strncmp(opt, data, strlen(opt))) - RETURN(NULL); + return NULL; if ((value = strchr(data, '=')) == NULL) - RETURN(NULL); + return NULL; value++; OBD_ALLOC(retval, strlen(value) + 1); if (!retval) { CERROR("out of memory!\n"); - RETURN(NULL); + return NULL; } memcpy(retval, value, strlen(value)+1); CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - RETURN(retval); + return retval; } static inline int ll_set_opt(const char *opt, char *data, int fl) @@ -765,10 +755,9 @@ static int ll_options(char *options, int *flags) { int tmp; char *s1 = options, *s2; - ENTRY; if (!options) - RETURN(0); + return 0; CDEBUG(D_CONFIG, "Parsing opts %s\n", options); @@ -891,7 +880,7 @@ static int ll_options(char *options, int *flags) } LCONSOLE_ERROR_MSG(0x152, "Unknown option '%s', won't mount.\n", s1); - RETURN(-EINVAL); + return -EINVAL; next: /* Find next opt */ @@ -900,7 +889,7 @@ next: break; s1 = s2 + 1; } - RETURN(0); + return 0; } void ll_lli_init(struct ll_inode_info *lli) @@ -977,13 +966,12 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); OBD_ALLOC_PTR(cfg); if (cfg == NULL) - RETURN(-ENOMEM); + return -ENOMEM; try_module_get(THIS_MODULE); @@ -992,7 +980,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) if (!sbi) { module_put(THIS_MODULE); OBD_FREE_PTR(cfg); - RETURN(-ENOMEM); + return -ENOMEM; } err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); @@ -1058,7 +1046,7 @@ out_free: LCONSOLE_WARN("Mounted %s\n", profilenm); OBD_FREE_PTR(cfg); - RETURN(err); + return err; } /* ll_fill_super */ void ll_put_super(struct super_block *sb) @@ -1069,7 +1057,6 @@ void ll_put_super(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); char *profilenm = get_profile_name(sb); int next, force = 1; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm); @@ -1121,8 +1108,6 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); module_put(THIS_MODULE); - - EXIT; } /* client_put_super */ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) @@ -1176,7 +1161,6 @@ void ll_clear_inode(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -1188,7 +1172,9 @@ void ll_clear_inode(struct inode *inode) LASSERT(lli->lli_opendir_pid == 0); } + spin_lock(&lli->lli_lock); ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode)); LASSERT(!lli->lli_open_fd_write_count); @@ -1235,8 +1221,6 @@ void ll_clear_inode(struct inode *inode) */ cl_inode_fini(inode); lli->lli_has_smd = false; - - EXIT; } int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, @@ -1247,12 +1231,11 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *request = NULL; int rc, ia_valid; - ENTRY; op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request, mod); @@ -1272,14 +1255,14 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, } else if (rc != -EPERM && rc != -EACCES && rc != -ETXTBSY) { CERROR("md_setattr fails: rc = %d\n", rc); } - RETURN(rc); + return rc; } rc = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) { ptlrpc_req_finished(request); - RETURN(rc); + return rc; } ia_valid = op_data->op_attr.ia_valid; @@ -1296,7 +1279,7 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, ll_update_inode(inode, &md); ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /* Close IO epoch and send Size-on-MDS attribute update. */ @@ -1306,11 +1289,10 @@ static int ll_setattr_done_writing(struct inode *inode, { struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; LASSERT(op_data != NULL); if (!S_ISREG(inode->i_mode)) - RETURN(0); + return 0; CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n", op_data->op_ioepoch, PFID(&lli->lli_fid)); @@ -1328,7 +1310,7 @@ static int ll_setattr_done_writing(struct inode *inode, CERROR("inode %lu mdc truncate failed: rc = %d\n", inode->i_ino, rc); } - RETURN(rc); + return rc; } static int ll_setattr_ost(struct inode *inode, struct iattr *attr) @@ -1372,7 +1354,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; int rc = 0, rc1 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "%s: setattr inode %p/fid:"DFID" from %llu to %llu, " "valid %x\n", ll_get_fsname(inode->i_sb, NULL, 0), inode, @@ -1383,7 +1364,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* Check new size against VFS/VM file size limit and rlimit */ rc = inode_newsize_ok(inode, attr->ia_size); if (rc) - RETURN(rc); + return rc; /* The maximum Lustre file size is variable, based on the * OST maximum object size and number of stripes. This @@ -1392,7 +1373,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) CDEBUG(D_INODE,"file "DFID" too large %llu > "LPU64"\n", PFID(&lli->lli_fid), attr->ia_size, ll_file_maxbytes(inode)); - RETURN(-EFBIG); + return -EFBIG; } attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; @@ -1400,24 +1381,24 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ if (attr->ia_valid & TIMES_SET_FLAGS) { - if (current_fsuid() != inode->i_uid && + if ((!uid_eq(current_fsuid(), inode->i_uid)) && !cfs_capable(CFS_CAP_FOWNER)) - RETURN(-EPERM); + return -EPERM; } /* We mark all of the fields "set" so MDS/OST does not re-set them */ if (attr->ia_valid & ATTR_CTIME) { - attr->ia_ctime = CFS_CURRENT_TIME; + attr->ia_ctime = CURRENT_TIME; attr->ia_valid |= ATTR_CTIME_SET; } if (!(attr->ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) { - attr->ia_atime = CFS_CURRENT_TIME; + attr->ia_atime = CURRENT_TIME; attr->ia_valid |= ATTR_ATIME_SET; } if (!(attr->ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) { - attr->ia_mtime = CFS_CURRENT_TIME; + attr->ia_mtime = CURRENT_TIME; attr->ia_valid |= ATTR_MTIME_SET; } @@ -1439,7 +1420,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) OBD_ALLOC_PTR(op_data); if (op_data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!S_ISDIR(inode->i_mode)) { if (attr->ia_valid & ATTR_SIZE) @@ -1480,7 +1461,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) * setting times to past, but it is necessary due to possible * time de-synchronization between MDT inode and OST objects */ rc = ll_setattr_ost(inode, attr); - EXIT; out: if (op_data) { if (op_data->op_ioepoch) { @@ -1537,12 +1517,11 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; int rc; - ENTRY; rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags); if (rc) { CERROR("md_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } osfs->os_type = sb->s_magic; @@ -1556,7 +1535,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, rc = obd_statfs_rqset(sbi->ll_dt_exp, &obd_osfs, max_age, flags); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", @@ -1578,7 +1557,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, osfs->os_ffree = obd_osfs.os_ffree; } - RETURN(rc); + return rc; } int ll_statfs(struct dentry *de, struct kstatfs *sfs) { @@ -1615,7 +1594,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) sfs->f_blocks = osfs.os_blocks; sfs->f_bfree = osfs.os_bfree; sfs->f_bavail = osfs.os_bavail; - + sfs->f_fsid = ll_s2sbi(sb)->ll_fsid; return 0; } @@ -1707,9 +1686,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_blkbits = inode->i_sb->s_blocksize_bits; } if (body->valid & OBD_MD_FLUID) - inode->i_uid = body->uid; + inode->i_uid = make_kuid(&init_user_ns, body->uid); if (body->valid & OBD_MD_FLGID) - inode->i_gid = body->gid; + inode->i_gid = make_kgid(&init_user_ns, body->gid); if (body->valid & OBD_MD_FLFLAGS) inode->i_flags = ll_ext_to_inode_flags(body->flags); if (body->valid & OBD_MD_FLNLINK) @@ -1755,7 +1734,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) /* Use old size assignment to avoid * deadlock bz14138 & bz14326 */ i_size_write(inode, body->size); + spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); } ldlm_lock_decref(&lockh, mode); } @@ -1786,7 +1767,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) { struct lustre_md *md = opaque; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", PFID(&lli->lli_fid), inode); @@ -1814,28 +1794,22 @@ void ll_read_inode2(struct inode *inode, void *opaque) inode->i_op = &ll_file_inode_operations; inode->i_fop = sbi->ll_fop; inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops; - EXIT; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ll_dir_inode_operations; inode->i_fop = &ll_dir_operations; - EXIT; } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &ll_fast_symlink_inode_operations; - EXIT; } else { inode->i_op = &ll_special_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); - - EXIT; } } void ll_delete_inode(struct inode *inode) { struct cl_inode_info *lli = cl_i2info(inode); - ENTRY; if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) /* discard all dirty pages before truncating them, required by @@ -1859,8 +1833,6 @@ void ll_delete_inode(struct inode *inode) ll_clear_inode(inode); clear_inode(inode); - - EXIT; } int ll_iocontrol(struct inode *inode, struct file *file, @@ -1869,7 +1841,6 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; int rc, flags = 0; - ENTRY; switch(cmd) { case FSFILT_IOC_GETFLAGS: { @@ -1880,14 +1851,14 @@ int ll_iocontrol(struct inode *inode, struct file *file, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLFLAGS; rc = md_getattr(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); - RETURN(-abs(rc)); + return -abs(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -1896,7 +1867,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, ptlrpc_req_finished(req); - RETURN(put_user(flags, (int *)arg)); + return put_user(flags, (int *)arg); } case FSFILT_IOC_SETFLAGS: { struct lov_stripe_md *lsm; @@ -1904,12 +1875,12 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct md_op_data *op_data; if (get_user(flags, (int *)arg)) - RETURN(-EFAULT); + return -EFAULT; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags = flags; op_data->op_attr.ia_valid |= ATTR_ATTR_FLAG; @@ -1918,18 +1889,20 @@ int ll_iocontrol(struct inode *inode, struct file *file, ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); if (rc) - RETURN(rc); + return rc; inode->i_flags = ll_ext_to_inode_flags(flags); lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) - RETURN(0); + if (!lsm_has_objects(lsm)) { + ccc_inode_lsm_put(inode, lsm); + return 0; + } OBDO_ALLOC(oinfo.oi_oa); if (!oinfo.oi_oa) { ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); + return -ENOMEM; } oinfo.oi_md = lsm; oinfo.oi_oa->o_oi = lsm->lsm_oi; @@ -1946,20 +1919,21 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (rc && rc != -EPERM && rc != -EACCES) CERROR("osc_setattr_async fails: rc = %d\n", rc); - RETURN(rc); + return rc; } default: - RETURN(-ENOSYS); + return -ENOSYS; } - RETURN(0); + return 0; } int ll_flush_ctx(struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); - CDEBUG(D_SEC, "flush context for user %d\n", current_uid()); + CDEBUG(D_SEC, "flush context for user %d\n", + from_kuid(&init_user_ns, current_uid())); obd_set_info_async(NULL, sbi->ll_md_exp, sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX, @@ -1976,8 +1950,6 @@ void ll_umount_begin(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_ioctl_data *ioc_data; - ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); @@ -1986,7 +1958,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid MDC connection handle "LPX64"\n", sbi->ll_md_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -1995,7 +1966,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid LOV connection handle "LPX64"\n", sbi->ll_dt_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -2016,8 +1986,6 @@ void ll_umount_begin(struct super_block *sb) * schedule() and sleep one second if needed, and hope. */ schedule(); - - EXIT; } int ll_remount_fs(struct super_block *sb, int *flags, char *data) @@ -2058,14 +2026,13 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct ll_sb_info *sbi = NULL; struct lustre_md md; int rc; - ENTRY; LASSERT(*inode || sb); sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode); rc = md_get_lustre_md(sbi->ll_md_exp, req, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) - RETURN(rc); + return rc; if (*inode) { ll_update_inode(*inode, &md); @@ -2127,7 +2094,7 @@ out: if (md.lsm != NULL) obd_free_memmd(sbi->ll_dt_exp, &md.lsm); md_free_lustre_md(sbi->ll_md_exp, &md); - RETURN(rc); + return rc; } int ll_obd_statfs(struct inode *inode, void *arg) @@ -2238,8 +2205,8 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_namelen = namelen; op_data->op_mode = mode; op_data->op_mod_time = cfs_time_current_sec(); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); + op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); op_data->op_bias = 0; op_data->op_cli_flags = 0; @@ -2303,7 +2270,7 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) if (sbi->ll_flags & LL_SBI_USER_FID2PATH) seq_puts(seq, ",user_fid2path"); - RETURN(0); + return 0; } /** @@ -2313,23 +2280,22 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) { struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_device *obd; - ENTRY; if (cmd == OBD_IOC_GETDTNAME) obd = class_exp2obd(sbi->ll_dt_exp); else if (cmd == OBD_IOC_GETMDNAME) obd = class_exp2obd(sbi->ll_md_exp); else - RETURN(-EINVAL); + return -EINVAL; if (!obd) - RETURN(-ENOENT); + return -ENOENT; if (copy_to_user((void *)arg, obd->obd_name, strlen(obd->obd_name) + 1)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } /** diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index d9590d85634a..caed6423e4ef 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -40,13 +40,9 @@ #include <linux/stat.h> #include <linux/errno.h> #include <linux/unistd.h> -#include <linux/version.h> #include <asm/uaccess.h> #include <linux/fs.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> #define DEBUG_SUBSYSTEM S_LLITE @@ -74,7 +70,6 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, size_t count) { struct vm_area_struct *vma, *ret = NULL; - ENTRY; /* mmap_sem must have been held by caller. */ LASSERT(!down_write_trylock(&mm->mmap_sem)); @@ -87,7 +82,7 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, break; } } - RETURN(ret); + return ret; } /** @@ -107,16 +102,16 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, struct cl_env_nest *nest, pgoff_t index, unsigned long *ra_flags) { - struct file *file = vma->vm_file; - struct inode *inode = file->f_dentry->d_inode; - struct cl_io *io; - struct cl_fault_io *fio; - struct lu_env *env; - ENTRY; + struct file *file = vma->vm_file; + struct inode *inode = file->f_dentry->d_inode; + struct cl_io *io; + struct cl_fault_io *fio; + struct lu_env *env; + int rc; *env_ret = NULL; if (ll_file_nolock(file)) - RETURN(ERR_PTR(-EOPNOTSUPP)); + return ERR_PTR(-EOPNOTSUPP); /* * page fault can be called when lustre IO is @@ -127,7 +122,7 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, */ env = cl_env_nested_get(nest); if (IS_ERR(env)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); *env_ret = env; @@ -152,17 +147,22 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, CDEBUG(D_MMAP, "vm_flags: %lx (%lu %d)\n", vma->vm_flags, fio->ft_index, fio->ft_executable); - if (cl_io_init(env, io, CIT_FAULT, io->ci_obj) == 0) { + rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj); + if (rc == 0) { struct ccc_io *cio = ccc_env_io(env); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); LASSERT(cio->cui_cl.cis_io == io); - /* mmap lock must be MANDATORY - * it has to cache pages. */ + /* mmap lock must be MANDATORY it has to cache + * pages. */ io->ci_lockreq = CILR_MANDATORY; - - cio->cui_fd = fd; + cio->cui_fd = fd; + } else { + LASSERT(rc < 0); + cl_io_fini(env, io); + cl_env_nested_put(nest, env); + io = ERR_PTR(rc); } return io; @@ -180,7 +180,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, sigset_t set; struct inode *inode; struct ll_inode_info *lli; - ENTRY; LASSERT(vmpage != NULL); @@ -190,7 +189,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, result = io->ci_result; if (result < 0) - GOTO(out, result); + GOTO(out_io, result); io->u.ci_fault.ft_mkwrite = 1; io->u.ci_fault.ft_writable = 1; @@ -250,16 +249,15 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, spin_unlock(&lli->lli_lock); } } - EXIT; -out: +out_io: cl_io_fini(env, io); cl_env_nested_put(&nest, env); - +out: CDEBUG(D_MMAP, "%s mkwrite with %d\n", current->comm, result); - LASSERT(ergo(result == 0, PageLocked(vmpage))); - return(result); + + return result; } @@ -304,11 +302,10 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) struct cl_env_nest nest; int result; int fault_ret = 0; - ENTRY; io = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags); if (IS_ERR(io)) - RETURN(to_fault_error(PTR_ERR(io))); + return to_fault_error(PTR_ERR(io)); result = io->ci_result; if (result == 0) { @@ -335,7 +332,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, result); - RETURN(fault_ret); + return fault_ret; } static int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) @@ -431,11 +428,9 @@ static void ll_vm_open(struct vm_area_struct * vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); atomic_inc(&vob->cob_mmap_cnt); - EXIT; } /** @@ -446,11 +441,9 @@ static void ll_vm_close(struct vm_area_struct *vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); atomic_dec(&vob->cob_mmap_cnt); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); - EXIT; } @@ -466,7 +459,6 @@ static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte) int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) { int rc = -ENOENT; - ENTRY; LASSERTF(last > first, "last "LPU64" first "LPU64"\n", last, first); if (mapping_mapped(mapping)) { @@ -475,7 +467,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) last - first + 1, 0); } - RETURN(rc); + return rc; } static struct vm_operations_struct ll_file_vm_ops = { @@ -489,10 +481,9 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) { struct inode *inode = file->f_dentry->d_inode; int rc; - ENTRY; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_MAP, 1); rc = generic_file_mmap(file, vma); @@ -503,5 +494,5 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 28cc41e90581..1767c741fb72 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -58,6 +58,22 @@ __u32 get_uuid2int(const char *name, int len) return (key0 << 1); } +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid) +{ + __u64 key = 0, key0 = 0x12a3fe2d, key1 = 0x37abe8f9; + + while (len--) { + key = key1 + (key0 ^ (*name++ * 7152373)); + if (key & 0x8000000000000000ULL) + key -= 0x7fffffffffffffffULL; + key1 = key0; + key0 = key; + } + + fsid->val[0] = key; + fsid->val[1] = key >> 32; +} + static int ll_nfs_test_inode(struct inode *inode, void *opaque) { return lu_fid_eq(&ll_i2info(inode)->lli_fid, @@ -75,17 +91,16 @@ struct inode *search_inode_for_lustre(struct super_block *sb, ll_need_32bit_api(sbi)); struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid)); inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid); if (inode) - RETURN(inode); + return inode; rc = ll_get_max_mdsize(sbi, &eadatalen); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not * be used here. So we allocate op_data ourselves */ @@ -103,14 +118,14 @@ struct inode *search_inode_for_lustre(struct super_block *sb, if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } rc = ll_prep_inode(&inode, req, sb, NULL); ptlrpc_req_finished(req); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); - RETURN(inode); + return inode; } struct lustre_nfs_fid { @@ -123,20 +138,19 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren { struct inode *inode; struct dentry *result; - ENTRY; CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid)); if (!fid_is_sane(fid)) - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); inode = search_inode_for_lustre(sb, fid); if (IS_ERR(inode)) - RETURN(ERR_PTR(PTR_ERR(inode))); + return ERR_CAST(inode); if (is_bad_inode(inode)) { /* we didn't find the right inode.. */ iput(inode); - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); } /** @@ -154,11 +168,11 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren result = d_obtain_alias(inode); if (IS_ERR(result)) - RETURN(result); + return result; ll_dops_init(result, 1, 0); - RETURN(result); + return result; } #define LUSTRE_NFS_FID 0x97 @@ -176,20 +190,19 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, struct inode *parent) { struct lustre_nfs_fid *nfs_fid = (void *)fh; - ENTRY; CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", inode->i_ino, PFID(ll_inode2fid(inode)), *plen, (int)sizeof(struct lustre_nfs_fid)); if (*plen < sizeof(struct lustre_nfs_fid) / 4) - RETURN(255); + return 255; nfs_fid->lnf_child = *ll_inode2fid(inode); nfs_fid->lnf_parent = *ll_inode2fid(parent); *plen = sizeof(struct lustre_nfs_fid) / 4; - RETURN(LUSTRE_NFS_FID); + return LUSTRE_NFS_FID; } static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, @@ -214,10 +227,12 @@ static int ll_get_name(struct dentry *dentry, char *name, struct dentry *child) { struct inode *dir = dentry->d_inode; - struct ll_getname_data lgd; - __u64 offset = 0; int rc; - ENTRY; + struct ll_getname_data lgd = { + .lgd_name = name, + .lgd_fid = ll_i2info(child->d_inode)->lli_fid, + .ctx.actor = ll_nfs_get_name_filldir, + }; if (!dir || !S_ISDIR(dir->i_mode)) GOTO(out, rc = -ENOTDIR); @@ -225,17 +240,11 @@ static int ll_get_name(struct dentry *dentry, char *name, if (!dir->i_fop) GOTO(out, rc = -EINVAL); - lgd.lgd_name = name; - lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid; - lgd.lgd_found = 0; - mutex_lock(&dir->i_mutex); - rc = ll_dir_read(dir, &offset, &lgd, ll_nfs_get_name_filldir); + rc = ll_dir_read(dir, &lgd.ctx); mutex_unlock(&dir->i_mutex); if (!rc && !lgd.lgd_found) rc = -ENOENT; - EXIT; - out: return rc; } @@ -246,9 +255,9 @@ static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent); } static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, @@ -257,9 +266,9 @@ static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL); } static struct dentry *ll_get_parent(struct dentry *dchild) @@ -273,7 +282,6 @@ static struct dentry *ll_get_parent(struct dentry *dchild) struct md_op_data *op_data; int rc; int lmmsize; - ENTRY; LASSERT(dir && S_ISDIR(dir->i_mode)); @@ -284,19 +292,19 @@ static struct dentry *ll_get_parent(struct dentry *dchild) rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc != 0) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot, strlen(dotdot), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body->valid & OBD_MD_FLID); @@ -307,7 +315,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild) result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL); ptlrpc_req_finished(req); - RETURN(result); + return result; } struct export_operations lustre_export_operations = { diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 9d4c17ea8808..2340458b8a04 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -99,7 +99,6 @@ #include <linux/completion.h> #include <linux/highmem.h> #include <linux/gfp.h> -#include <linux/swap.h> #include <linux/pagevec.h> #include <asm/uaccess.h> @@ -574,7 +573,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, lo->lo_offset = 0; lo->lo_sizelimit = 0; lo->lo_flags = 0; - ll_invalidate_bdev(bdev, 0); + invalidate_bdev(bdev); set_capacity(disks[lo->lo_number], 0); bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); @@ -618,7 +617,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LL_IOC_LLOOP_DETACH: { err = loop_clr_fd(lo, bdev, 2); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } @@ -713,7 +712,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, err = loop_set_fd(lo, NULL, bdev, file); if (err) { fput(file); - ll_blkdev_put(bdev, 0); + blkdev_put(bdev, 0); } break; @@ -737,7 +736,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, bdev = lo->lo_device; err = loop_clr_fd(lo, bdev, 1); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } @@ -849,10 +848,8 @@ static void lloop_exit(void) blk_cleanup_queue(loop_dev[i].lo_queue); put_disk(disks[i]); } - if (ll_unregister_blkdev(lloop_major, "lloop")) - CWARN("lloop: cannot unregister blkdev\n"); - else - CDEBUG(D_CONFIG, "unregistered lloop major %d\n", lloop_major); + + unregister_blkdev(lloop_major, "lloop"); OBD_FREE(disks, max_loop * sizeof(*disks)); OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 6a82505c7933..d4d3c17547ca 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include <linux/version.h> #include <lustre_lite.h> #include <lprocfs_status.h> #include <linux/seq_file.h> @@ -243,9 +242,9 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file, const char *buff if (rc) return rc; - if (pages_number < 0 || pages_number > num_physpages / 2) { + if (pages_number < 0 || pages_number > totalram_pages / 2) { CERROR("can't set file readahead more than %lu MB\n", - num_physpages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ + totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; } @@ -380,23 +379,22 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, int mult, rc, pages_number; int diff = 0; int nrpages = 0; - ENTRY; mult = 1 << (20 - PAGE_CACHE_SHIFT); buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count); rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) - RETURN(rc); + return rc; - if (pages_number < 0 || pages_number > num_physpages) { + if (pages_number < 0 || pages_number > totalram_pages) { CERROR("%s: can't set max cache more than %lu MB\n", ll_get_fsname(sb, NULL, 0), - num_physpages >> (20 - PAGE_CACHE_SHIFT)); - RETURN(-ERANGE); + totalram_pages >> (20 - PAGE_CACHE_SHIFT)); + return -ERANGE; } if (sbi->ll_dt_exp == NULL) - RETURN(-ENODEV); + return -ENODEV; spin_lock(&sbi->ll_lock); diff = pages_number - cache->ccc_lru_max; @@ -421,7 +419,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, break; nv = ov > diff ? ov - diff : 0; - rc = cfs_atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); + rc = atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); if (likely(ov == rc)) { diff -= ov - nv; nrpages += ov - nv; @@ -822,7 +820,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) sbi->ll_stats_track_id == current->parent->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_GID && - sbi->ll_stats_track_id == current_gid()) + sbi->ll_stats_track_id == + from_kgid(&init_user_ns, current_gid())) lprocfs_counter_add(sbi->ll_stats, op, count); } EXPORT_SYMBOL(ll_stats_ops_tally); @@ -852,10 +851,9 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - proc_dir_entry_t *dir; + struct proc_dir_entry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - ENTRY; memset(lvars, 0, sizeof(lvars)); @@ -880,7 +878,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, if (IS_ERR(sbi->ll_proc_root)) { err = PTR_ERR(sbi->ll_proc_root); sbi->ll_proc_root = NULL; - RETURN(err); + return err; } rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, @@ -994,7 +992,7 @@ out: lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } - RETURN(err); + return err; } void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) @@ -1302,8 +1300,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* We stored the discontiguous offsets here; print them first */ for(i = 0; i < LL_OFFSET_HIST_MAX; i++) { if (offset[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - offset[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + offset[i].rw_op == READ ? 'R' : 'W', offset[i].rw_pid, offset[i].rw_range_start, offset[i].rw_range_end, @@ -1314,8 +1313,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* Then print the current offsets for each process */ for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - process[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + process[i].rw_op == READ ? 'R' : 'W', process[i].rw_pid, process[i].rw_range_start, process[i].rw_last_file_pos, diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index ff8f63de5612..34815b550e71 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -77,11 +77,9 @@ static int ll_d_mountpoint(struct dentry *dparent, struct dentry *dchild, int ll_unlock(__u32 mode, struct lustre_handle *lockh) { - ENTRY; - ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } @@ -139,7 +137,6 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, struct lustre_md *md) { struct inode *inode; - ENTRY; LASSERT(hash != 0); inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md); @@ -169,7 +166,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, CDEBUG(D_VFSTRACE, "got inode: %p for "DFID"\n", inode, PFID(&md->body->fid1)); } - RETURN(inode); + return inode; } static void ll_invalidate_negative_children(struct inode *dir) @@ -200,7 +197,6 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, { int rc; struct lustre_handle lockh; - ENTRY; switch (flag) { case LDLM_CB_BLOCKING: @@ -208,7 +204,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, rc = ldlm_cli_cancel(&lockh, LCF_ASYNC); if (rc < 0) { CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc); - RETURN(rc); + return rc; } break; case LDLM_CB_CANCELING: { @@ -275,8 +271,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, CDEBUG(D_INODE, "invaliding layout %d.\n", rc); } - if (bits & MDS_INODELOCK_UPDATE) + if (bits & MDS_INODELOCK_UPDATE) { + spin_lock(&lli->lli_lock); lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); + } if (S_ISDIR(inode->i_mode) && (bits & MDS_INODELOCK_UPDATE)) { @@ -297,13 +296,13 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, LBUG(); } - RETURN(0); + return 0; } __u32 ll_i2suppgid(struct inode *i) { - if (current_is_in_group(i->i_gid)) - return (__u32)i->i_gid; + if (in_group_p(i->i_gid)) + return (__u32)from_kgid(&init_user_ns, i->i_gid); else return (__u32)(-1); } @@ -430,7 +429,6 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, struct inode *inode = NULL; __u64 bits = 0; int rc; - ENTRY; /* NB 1 request reference will be taken away by ll_intent_lock() * when I return */ @@ -439,7 +437,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, if (!it_disposition(it, DISP_LOOKUP_NEG)) { rc = ll_prep_inode(&inode, request, (*de)->d_sb, it); if (rc) - RETURN(rc); + return rc; ll_set_lock_data(ll_i2sbi(parent)->ll_md_exp, inode, it, &bits); @@ -480,7 +478,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, } } - RETURN(0); + return 0; } static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, @@ -493,10 +491,9 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct it_cb_data icbd; __u32 opc; int rc; - ENTRY; if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen) - RETURN(ERR_PTR(-ENAMETOOLONG)); + return ERR_PTR(-ENAMETOOLONG); CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, parent->i_ino, @@ -514,7 +511,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, rc = ll_inode_revalidate_it(parent->i_sb->s_root, it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } if (it->it_op == IT_GETATTR) { @@ -539,7 +536,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, dentry->d_name.len, lookup_flags, opc, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; /* enforce umask if acl disabled or MDS doesn't support umask */ if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent))) @@ -618,7 +615,6 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, struct dentry *de; long long lookup_flags = LOOKUP_OPEN; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),file %p," "open_flags %x,mode %x opened %d\n", @@ -627,7 +623,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, OBD_ALLOC(it, sizeof(*it)); if (!it) - RETURN(-ENOMEM); + return -ENOMEM; it->it_op = IT_OPEN; if (mode) { @@ -686,7 +682,7 @@ out_release: ll_intent_release(it); OBD_FREE(it, sizeof(*it)); - RETURN(rc); + return rc; } @@ -700,7 +696,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, struct ptlrpc_request *request = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); int rc; - ENTRY; LASSERT(it && it->d.lustre.it_disposition); @@ -719,7 +714,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL); - EXIT; out: ptlrpc_req_finished(request); return inode; @@ -744,7 +738,6 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, { struct inode *inode; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, dir->i_ino, @@ -752,18 +745,18 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, rc = it_open_error(DISP_OPEN_CREATE, it); if (rc) - RETURN(rc); + return rc; inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, 0, it); if (IS_ERR(inode)) - RETURN(PTR_ERR(inode)); + return PTR_ERR(inode); if (filename_is_volatile(dentry->d_name.name, dentry->d_name.len, NULL)) ll_i2info(inode)->lli_volatile = true; d_instantiate(dentry, inode); - RETURN(0); + return 0; } static void ll_update_times(struct ptlrpc_request *request, @@ -795,7 +788,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, int tgt_len = 0; int err; - ENTRY; if (unlikely(tgt != NULL)) tgt_len = strlen(tgt) + 1; @@ -805,7 +797,8 @@ static int ll_new_node(struct inode *dir, struct qstr *name, GOTO(err_exit, err = PTR_ERR(op_data)); err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), rdev, &request); ll_finish_md_op_data(op_data); if (err) @@ -820,7 +813,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, d_instantiate(dchild, inode); } - EXIT; err_exit: ptlrpc_req_finished(request); @@ -831,7 +823,6 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, unsigned rdev, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p) mode %o dev %x\n", name->len, name->name, dir->i_ino, dir->i_generation, dir, @@ -861,7 +852,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1); - RETURN(err); + return err; } /* @@ -891,7 +882,6 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, const char *tgt, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),target=%.*s\n", name->len, name->name, dir->i_ino, dir->i_generation, @@ -903,7 +893,7 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_SYMLINK, 1); - RETURN(err); + return err; } static int ll_link_generic(struct inode *src, struct inode *dir, @@ -914,7 +904,6 @@ static int ll_link_generic(struct inode *src, struct inode *dir, struct md_op_data *op_data; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: inode=%lu/%u(%p), dir=%lu/%u(%p), target=%.*s\n", src->i_ino, src->i_generation, src, dir->i_ino, @@ -923,7 +912,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); err = md_link(sbi->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -932,10 +921,9 @@ static int ll_link_generic(struct inode *src, struct inode *dir, ll_update_times(request, dir); ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); - EXIT; out: ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mkdir_generic(struct inode *dir, struct qstr *name, @@ -943,7 +931,6 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -956,7 +943,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKDIR, 1); - RETURN(err); + return err; } /* Try to find the child dentry by its name. @@ -981,18 +968,17 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -1004,7 +990,7 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /** @@ -1015,7 +1001,6 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", namelen, name, dir->i_ino, dir->i_generation, dir); @@ -1023,7 +1008,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) op_data = ll_prep_md_op_data(NULL, dir, NULL, name, strlen(name), S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_cli_flags |= CLI_RM_ENTRY; rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -1033,7 +1018,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) @@ -1045,12 +1030,11 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) struct obdo *oa; struct obd_capa *oc = NULL; int rc; - ENTRY; /* req is swabbed so this is safe */ body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); if (!(body->valid & OBD_MD_FLEASIZE)) - RETURN(0); + return 0; if (body->eadatasize == 0) { CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); @@ -1122,7 +1106,6 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -1131,12 +1114,12 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, * just check it as vfs_unlink does. */ if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -1151,7 +1134,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, rc = ll_objects_destroy(request, dir); out: ptlrpc_req_finished(request); - RETURN(rc); + return rc; } static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, @@ -1163,7 +1146,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, struct ll_sb_info *sbi = ll_i2sbi(src); struct md_op_data *op_data; int err; - ENTRY; + CDEBUG(D_VFSTRACE,"VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s," "tgt_dir=%lu/%u(%p)\n", src_name->len, src_name->name, src->i_ino, src->i_generation, src, tgt_name->len, @@ -1171,12 +1154,12 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, if (unlikely(ll_d_mountpoint(src_dparent, src_dchild, src_name) || ll_d_mountpoint(tgt_dparent, tgt_dchild, tgt_name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(src, src_name, &op_data->op_fid3); ll_get_child_fid(tgt, tgt_name, &op_data->op_fid4); @@ -1193,7 +1176,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode, diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 68b2dc4a7b62..dedd56ae1e6d 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -45,7 +45,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <lustre_lite.h> #include <lustre_ha.h> @@ -124,22 +123,22 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) struct hlist_head *head; struct ll_remote_perm *lrp; int found = 0, rc; - ENTRY; if (!lli->lli_remote_perms) - RETURN(-ENOENT); + return -ENOENT; - head = lli->lli_remote_perms + remote_perm_hashfunc(current_uid()); + head = lli->lli_remote_perms + + remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid())); spin_lock(&lli->lli_lock); hlist_for_each_entry(lrp, head, lrp_list) { - if (lrp->lrp_uid != current_uid()) + if (lrp->lrp_uid != from_kuid(&init_user_ns, current_uid())) continue; - if (lrp->lrp_gid != current_gid()) + if (lrp->lrp_gid != from_kgid(&init_user_ns, current_gid())) continue; - if (lrp->lrp_fsuid != current_fsuid()) + if (lrp->lrp_fsuid != from_kuid(&init_user_ns, current_fsuid())) continue; - if (lrp->lrp_fsgid != current_fsgid()) + if (lrp->lrp_fsgid != from_kgid(&init_user_ns, current_fsgid())) continue; found = 1; break; @@ -163,7 +162,6 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) struct ll_inode_info *lli = ll_i2info(inode); struct ll_remote_perm *lrp = NULL, *tmp = NULL; struct hlist_head *head, *perm_hash = NULL; - ENTRY; LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT); @@ -178,7 +176,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm->rp_uid, perm->rp_gid, perm->rp_fsuid, perm->rp_fsgid, current->uid, current->gid, current->fsuid, current->fsgid); - RETURN(-EAGAIN); + return -EAGAIN; } #endif @@ -186,7 +184,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm_hash = alloc_rmtperm_hash(); if (perm_hash == NULL) { CERROR("alloc lli_remote_perms failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } } @@ -220,7 +218,7 @@ again: lrp = alloc_ll_remote_perm(); if (!lrp) { CERROR("alloc memory for ll_remote_perm failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } spin_lock(&lli->lli_lock); goto again; @@ -241,7 +239,7 @@ again: lrp, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, lrp->lrp_access_perm); - RETURN(0); + return 0; } int lustre_check_remote_perm(struct inode *inode, int mask) @@ -253,7 +251,6 @@ int lustre_check_remote_perm(struct inode *inode, int mask) struct obd_capa *oc; cfs_time_t save; int i = 0, rc; - ENTRY; do { save = lli->lli_rmtperm_time; @@ -304,7 +301,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask) req = NULL; } while (1); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } #if 0 /* NB: remote perms can't be freed in ll_mdc_blocking_ast of UPDATE lock, diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index fac117889011..ae0dc441d1d9 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -48,9 +48,6 @@ #include <asm/uaccess.h> #include <linux/fs.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> /* current_is_kswapd() */ #include <linux/swap.h> @@ -110,7 +107,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, env = cl_env_get(&refcheck); if (IS_ERR(env)) - return ERR_PTR(PTR_ERR(env)); + return ERR_CAST(env); lcc = &vvp_env_info(env)->vti_io_ctx; memset(lcc, 0, sizeof(*lcc)); @@ -132,7 +129,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, * add dirty pages into cache during truncate */ CERROR("Proc %s is dirting page w/o inode lock, this" "will break truncate.\n", current->comm); - libcfs_debug_dumpstack(NULL); + dump_stack(); LBUG(); return ERR_PTR(-EIO); } @@ -228,7 +225,6 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 1); if (!IS_ERR(lcc)) { @@ -256,7 +252,7 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, } else { result = PTR_ERR(lcc); } - RETURN(result); + return result; } int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, @@ -267,7 +263,6 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, struct cl_io *io; struct cl_page *page; int result = 0; - ENTRY; lcc = ll_cl_get(); env = lcc->lcc_env; @@ -287,7 +282,7 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, lu_ref_del(&page->cp_reference, "prepare_write", current); cl_page_put(env, page); ll_cl_fini(lcc); - RETURN(result); + return result; } struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt) @@ -325,7 +320,6 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, { struct ll_ra_info *ra = &sbi->ll_ra_info; long ret; - ENTRY; /* If read-ahead pages left are less than 1M, do not do read-ahead, * otherwise it will form small read RPC(< 1M), which hurt server @@ -357,7 +351,7 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, } out: - RETURN(ret); + return ret; } void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len) @@ -468,8 +462,6 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, struct ccc_page *cp; int rc; - ENTRY; - rc = 0; cl_page_assume(env, io, page); lu_ref_add(&page->cp_reference, "ra", current); @@ -491,7 +483,7 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, } lu_ref_del(&page->cp_reference, "ra", current); cl_page_put(env, page); - RETURN(rc); + return rc; } /** @@ -516,8 +508,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, int rc = 0; const char *msg = NULL; - ENTRY; - gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT; #ifdef __GFP_NOWARN gfp_mask |= __GFP_NOWARN; @@ -554,7 +544,7 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, ll_ra_stats_inc(mapping, which); CDEBUG(D_READA, "%s\n", msg); } - RETURN(rc); + return rc; } #define RIA_DEBUG(ria) \ @@ -722,7 +712,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, struct cl_object *clob; int ret = 0; __u64 kms; - ENTRY; inode = mapping->host; lli = ll_i2info(inode); @@ -735,11 +724,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, cl_object_attr_unlock(clob); if (ret != 0) - RETURN(ret); + return ret; kms = attr->cat_kms; if (kms == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_LEN); - RETURN(0); + return 0; } spin_lock(&ras->ras_lock); @@ -797,11 +786,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, if (end == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_WINDOW); - RETURN(0); + return 0; } len = ria_page_count(ria); if (len == 0) - RETURN(0); + return 0; reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len); if (reserved < len) @@ -840,7 +829,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, spin_unlock(&ras->ras_lock); } - RETURN(ret); + return ret; } static void ras_set_start(struct inode *inode, struct ll_readahead_state *ras, @@ -999,7 +988,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, { struct ll_ra_info *ra = &sbi->ll_ra_info; int zero = 0, stride_detect = 0, ra_miss = 0; - ENTRY; spin_lock(&ras->ras_lock); @@ -1135,7 +1123,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, if ((ras->ras_consecutive_requests > 1 || stride_detect) && !ras->ras_request_index) ras_increase_window(inode, ras, ra); - EXIT; out_unlock: RAS_CDEBUG(ras); ras->ras_request_index++; @@ -1155,7 +1142,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) bool redirtied = false; bool unlocked = false; int result; - ENTRY; LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); @@ -1247,7 +1233,6 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) int range_whole = 0; int result; int ignore_layout = 0; - ENTRY; if (wbc->range_cyclic) { start = mapping->writeback_index << PAGE_CACHE_SHIFT; @@ -1281,14 +1266,13 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) end = i_size_read(inode); mapping->writeback_index = (end >> PAGE_CACHE_SHIFT) + 1; } - RETURN(result); + return result; } int ll_readpage(struct file *file, struct page *vmpage) { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 0); if (!IS_ERR(lcc)) { @@ -1310,5 +1294,5 @@ int ll_readpage(struct file *file, struct page *vmpage) unlock_page(vmpage); result = PTR_ERR(lcc); } - RETURN(result); + return result; } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 27e4e64bc1e7..96c29ad2fc8c 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -51,9 +51,6 @@ #include <linux/buffer_head.h> #include <linux/mpage.h> #include <linux/writeback.h> -#include <linux/stat.h> -#include <asm/uaccess.h> -#include <linux/mm.h> #include <linux/pagemap.h> #define DEBUG_SUBSYSTEM S_LLITE @@ -72,7 +69,8 @@ * aligned truncate). Lustre leaves partially truncated page in the cache, * relying on struct inode::i_size to limit further accesses. */ -static void ll_invalidatepage(struct page *vmpage, unsigned long offset) +static void ll_invalidatepage(struct page *vmpage, unsigned int offset, + unsigned int length) { struct inode *inode; struct lu_env *env; @@ -89,7 +87,7 @@ static void ll_invalidatepage(struct page *vmpage, unsigned long offset) * below because they are run with page locked and all our io is * happening with locked page too */ - if (offset == 0) { + if (offset == 0 && length == PAGE_CACHE_SIZE) { env = cl_env_get(&refcheck); if (!IS_ERR(env)) { inode = vmpage->mapping->host; @@ -182,7 +180,7 @@ static int ll_set_page_dirty(struct page *vmpage) */ vvp_write_pending(obj, cpg); #endif - RETURN(__set_page_dirty_nobuffers(vmpage)); + return __set_page_dirty_nobuffers(vmpage); } #define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL @@ -249,7 +247,6 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, long page_size = cl_page_size(obj); bool do_io; int io_pages = 0; - ENTRY; queue = &io->ci_queue; cl_2queue_init(queue); @@ -286,11 +283,11 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, src_page = (rw == WRITE) ? pages[i] : vmpage; dst_page = (rw == WRITE) ? vmpage : pages[i]; - src = ll_kmap_atomic(src_page, KM_USER0); - dst = ll_kmap_atomic(dst_page, KM_USER1); + src = kmap_atomic(src_page); + dst = kmap_atomic(dst_page); memcpy(dst, src, min(page_size, size)); - ll_kunmap_atomic(dst, KM_USER1); - ll_kunmap_atomic(src, KM_USER0); + kunmap_atomic(dst); + kunmap_atomic(src); /* make sure page will be added to the transfer by * cl_io_submit()->...->vvp_page_prep_write(). */ @@ -335,7 +332,7 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, cl_2queue_discard(env, io, queue); cl_2queue_disown(env, io, queue); cl_2queue_fini(env, queue); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ll_direct_rw_pages); @@ -383,14 +380,13 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, unsigned long seg = 0; long size = MAX_DIO_SIZE; int refcheck; - ENTRY; if (!lli->lli_has_smd) - RETURN(-EBADF); + return -EBADF; /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ if ((file_offset & ~CFS_PAGE_MASK) || (count & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size=%lu (max %lu), " "offset=%lld=%llx, pages %lu (max %lu)\n", @@ -402,7 +398,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, for (seg = 0; seg < nr_segs; seg++) { if (((unsigned long)iov[seg].iov_base & ~CFS_PAGE_MASK) || (iov[seg].iov_len & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; } env = cl_env_get(&refcheck); @@ -495,7 +491,7 @@ out: } cl_env_put(env, &refcheck); - RETURN(tot_bytes ? : result); + return tot_bytes ? : result; } static int ll_write_begin(struct file *file, struct address_space *mapping, @@ -506,11 +502,10 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, struct page *page; int rc; unsigned from = pos & (PAGE_CACHE_SIZE - 1); - ENTRY; page = grab_cache_page_write_begin(mapping, index, flags); if (!page) - RETURN(-ENOMEM); + return -ENOMEM; *pagep = page; @@ -519,7 +514,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, unlock_page(page); page_cache_release(page); } - RETURN(rc); + return rc; } static int ll_write_end(struct file *file, struct address_space *mapping, diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 7747f8f2079d..8eaa38e91b99 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -200,12 +200,11 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, struct ll_sa_entry *entry; int entry_size; char *dname; - ENTRY; entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4; OBD_ALLOC(entry, entry_size); if (unlikely(entry == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); CDEBUG(D_READA, "alloc sa entry %.*s(%p) index "LPU64"\n", len, name, entry, index); @@ -254,7 +253,7 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, atomic_inc(&sai->sai_cache_count); - RETURN(entry); + return entry; } /* @@ -465,11 +464,10 @@ static struct ll_statahead_info *ll_sai_alloc(void) { struct ll_statahead_info *sai; int i; - ENTRY; OBD_ALLOC_PTR(sai); if (!sai) - RETURN(NULL); + return NULL; atomic_set(&sai->sai_refcount, 1); @@ -496,7 +494,7 @@ static struct ll_statahead_info *ll_sai_alloc(void) } atomic_set(&sai->sai_cache_count, 0); - RETURN(sai); + return sai; } static inline struct ll_statahead_info * @@ -510,7 +508,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) { struct inode *inode = sai->sai_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; if (atomic_dec_and_lock(&sai->sai_refcount, &lli->lli_sa_lock)) { struct ll_sa_entry *entry, *next; @@ -519,7 +516,7 @@ static void ll_sai_put(struct ll_statahead_info *sai) /* It is race case, the interpret callback just hold * a reference count */ spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } LASSERT(lli->lli_opendir_key == NULL); @@ -550,8 +547,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) iput(inode); OBD_FREE_PTR(sai); } - - EXIT; } /* Do NOT forget to drop inode refcount when into sai_entries_agl. */ @@ -560,7 +555,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) struct ll_inode_info *lli = ll_i2info(inode); __u64 index = lli->lli_agl_index; int rc; - ENTRY; LASSERT(list_empty(&lli->lli_agl_list)); @@ -568,7 +562,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (is_omitted_entry(sai, index + 1)) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* Someone is in glimpse (sync or async), do nothing. */ @@ -576,7 +570,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (rc == 0) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* @@ -597,7 +591,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) up_write(&lli->lli_glimpse_sem); lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } CDEBUG(D_READA, "Handling (init) async glimpse: inode = " @@ -613,8 +607,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) PFID(&lli->lli_fid), index, rc); iput(inode); - - EXIT; } static void ll_post_statahead(struct ll_statahead_info *sai) @@ -628,12 +620,11 @@ static void ll_post_statahead(struct ll_statahead_info *sai) struct ptlrpc_request *req; struct mdt_body *body; int rc = 0; - ENTRY; spin_lock(&lli->lli_sa_lock); if (unlikely(sa_received_empty(sai))) { spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } entry = sa_first_received_entry(sai); atomic_inc(&entry->se_refcount); @@ -690,8 +681,6 @@ static void ll_post_statahead(struct ll_statahead_info *sai) if (agl_should_run(sai, child)) ll_agl_add(sai, child, entry->se_index); - EXIT; - out: /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock * reference count by calling "ll_intent_drop_lock()" in spite of the @@ -713,7 +702,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, struct ll_statahead_info *sai = NULL; struct ll_sa_entry *entry; int wakeup; - ENTRY; if (it_disposition(it, DISP_LOOKUP_NEG)) rc = -ENOENT; @@ -763,8 +751,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, wake_up(&sai->sai_thread.t_ctl_waitq); } - EXIT; - out: if (rc != 0) { ll_intent_release(it); @@ -852,11 +838,10 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; rc = sa_args_init(dir, NULL, entry, &minfo, &einfo, capas); if (rc) - RETURN(rc); + return rc; rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); if (!rc) { @@ -866,7 +851,7 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } /** @@ -885,30 +870,29 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; if (unlikely(inode == NULL)) - RETURN(1); + return 1; if (d_mountpoint(dentry)) - RETURN(1); + return 1; if (unlikely(dentry == dentry->d_sb->s_root)) - RETURN(1); + return 1; entry->se_inode = igrab(inode); rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),NULL); if (rc == 1) { entry->se_handle = it.d.lustre.it_lock_handle; ll_intent_release(&it); - RETURN(1); + return 1; } rc = sa_args_init(dir, inode, entry, &minfo, &einfo, capas); if (rc) { entry->se_inode = NULL; iput(inode); - RETURN(rc); + return rc; } rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); @@ -921,7 +905,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } static void ll_statahead_one(struct dentry *parent, const char* entry_name, @@ -934,12 +918,11 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, struct ll_sa_entry *entry; int rc; int rc1; - ENTRY; entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name, entry_name_len); if (IS_ERR(entry)) - RETURN_EXIT; + return; dentry = d_lookup(parent, &entry->se_qstr); if (!dentry) { @@ -965,8 +948,6 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, sai->sai_index++; /* drop one refcount on entry by ll_sa_entry_alloc */ ll_sa_entry_put(sai, entry); - - EXIT; } static int ll_agl_thread(void *arg) @@ -979,7 +960,6 @@ static int ll_agl_thread(void *arg) struct ll_statahead_info *sai = ll_sai_get(plli->lli_sai); struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1029,7 +1009,7 @@ static int ll_agl_thread(void *arg) ll_sai_put(sai); CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); - RETURN(0); + return 0; } static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) @@ -1037,8 +1017,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; struct ll_inode_info *plli; - task_t *task; - ENTRY; + struct task_struct *task; CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1049,13 +1028,12 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) if (IS_ERR(task)) { CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task)); thread_set_flags(thread, SVC_STOPPED); - RETURN_EXIT; + return; } l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); - EXIT; } static int ll_statahead_thread(void *arg) @@ -1074,7 +1052,6 @@ static int ll_statahead_thread(void *arg) int rc = 0; struct ll_dir_chain chain; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1257,7 +1234,6 @@ do_it: */ } } - EXIT; out: if (sai->sai_agl_valid) { @@ -1369,7 +1345,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) __u64 pos = 0; int dot_de; int rc = LS_NONE_FIRST_DE; - ENTRY; ll_dir_chain_init(&chain); page = ll_get_dir_page(dir, pos, &chain); @@ -1468,7 +1443,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) ll_release_page(page, 1); } } - EXIT; out: ll_dir_chain_fini(&chain); @@ -1481,7 +1455,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) struct ptlrpc_thread *thread = &sai->sai_thread; struct ll_sb_info *sbi = ll_i2sbi(sai->sai_inode); int hit; - ENTRY; if (entry != NULL && entry->se_stat == SA_ENTRY_SUCC) hit = 1; @@ -1516,8 +1489,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) if (!thread_is_stopped(thread)) wake_up(&thread->t_ctl_waitq); - - EXIT; } /** @@ -1540,7 +1511,6 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, struct l_wait_info lwi = { 0 }; int rc = 0; struct ll_inode_info *plli; - ENTRY; LASSERT(lli->lli_opendir_pid == current_pid()); @@ -1550,7 +1520,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, list_empty(&sai->sai_entries_stated))) { /* to release resource */ ll_stop_statahead(dir, lli->lli_opendir_key); - RETURN(-EAGAIN); + return -EAGAIN; } if ((*dentryp)->d_name.name[0] == '.') { @@ -1576,14 +1546,14 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * "sai_ls_all" enabled as above. */ sai->sai_miss_hidden++; - RETURN(-EAGAIN); + return -EAGAIN; } } entry = ll_sa_entry_get_byname(sai, &(*dentryp)->d_name); if (entry == NULL || only_unplug) { ll_sai_unplug(sai, entry); - RETURN(entry ? 1 : -EAGAIN); + return entry ? 1 : -EAGAIN; } /* if statahead is busy in readdir, help it do post-work */ @@ -1602,7 +1572,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, &lwi); if (rc < 0) { ll_sai_unplug(sai, entry); - RETURN(-EAGAIN); + return -EAGAIN; } } @@ -1632,7 +1602,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, inode->i_ino, inode->i_generation); ll_sai_unplug(sai, entry); - RETURN(-ESTALE); + return -ESTALE; } else { iput(inode); } @@ -1646,7 +1616,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } ll_sai_unplug(sai, entry); - RETURN(rc); + return rc; } /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */ @@ -1698,7 +1668,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED); ll_sai_put(sai); LASSERT(lli->lli_sai == NULL); - RETURN(-EAGAIN); + return -EAGAIN; } l_wait_event(thread->t_ctl_waitq, @@ -1709,7 +1679,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * We don't stat-ahead for the first dirent since we are already in * lookup. */ - RETURN(-EAGAIN); + return -EAGAIN; out: if (sai != NULL) diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 82c14a993cca..0beaf4e76b4b 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -38,7 +38,6 @@ #include <linux/module.h> #include <linux/types.h> -#include <linux/version.h> #include <lustre_lite.h> #include <lustre_ha.h> #include <lustre_dlm.h> @@ -214,7 +213,7 @@ static void __exit exit_lustre_lite(void) ll_remote_perm_cachep = NULL; kmem_cache_destroy(ll_file_data_slab); - if (proc_lustre_fs_root) + if (proc_lustre_fs_root && !IS_ERR(proc_lustre_fs_root)) lprocfs_remove(&proc_lustre_fs_root); } diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 5260e989a4e5..ab06891f7fc7 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -37,7 +37,6 @@ #include <linux/fs.h> #include <linux/mm.h> #include <linux/stat.h> -#include <linux/version.h> #define DEBUG_SUBSYSTEM S_LLITE #include <lustre_lite.h> @@ -51,7 +50,6 @@ static int ll_readlink_internal(struct inode *inode, int rc, symlen = i_size_read(inode) + 1; struct mdt_body *body; struct md_op_data *op_data; - ENTRY; *request = NULL; @@ -65,13 +63,13 @@ static int ll_readlink_internal(struct inode *inode, CDEBUG(D_INODE, "using cached symlink %s%.*s, len = %d\n", print_limit < symlen ? "..." : "", print_limit, (*symname) + symlen - print_limit, symlen); - RETURN(0); + return 0; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_LINKNAME; rc = md_getattr(sbi->ll_md_exp, op_data, request); @@ -111,10 +109,10 @@ static int ll_readlink_internal(struct inode *inode, memcpy(lli->lli_symlink_name, *symname, symlen); *symname = lli->lli_symlink_name; } - RETURN(0); + return 0; failed: - RETURN (rc); + return rc; } static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) @@ -123,7 +121,6 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) struct ptlrpc_request *request; char *symname; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); @@ -136,7 +133,7 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) out: ptlrpc_req_finished(request); ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) @@ -145,7 +142,6 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) struct ptlrpc_request *request = NULL; int rc; char *symname; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); /* Limit the recursive symlink depth to 5 instead of default @@ -170,7 +166,7 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) /* symname may contain a pointer to the request message buffer, * we delay request releasing until ll_put_link then. */ - RETURN(request); + return request; } static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 9254b990d31c..be125b98b7f0 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -213,7 +213,7 @@ int cl_sb_init(struct super_block *sb) cl_env_put(env, &refcheck); } else rc = PTR_ERR(env); - RETURN(rc); + return rc; } int cl_sb_fini(struct super_block *sb) @@ -224,7 +224,6 @@ int cl_sb_fini(struct super_block *sb) int refcheck; int result; - ENTRY; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -247,7 +246,7 @@ int cl_sb_fini(struct super_block *sb) * automatically when last device is destroyed). */ lu_types_stop(); - RETURN(result); + return result; } /**************************************************************************** diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index eb964acad45c..3ff664ce7503 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -176,19 +176,18 @@ static int vvp_mmap_locks(const struct lu_env *env, unsigned long seg; ssize_t count; int result; - ENTRY; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); if (!cl_is_normalio(env, io)) - RETURN(0); + return 0; if (vio->cui_iov == NULL) /* nfs or loop back device write */ - RETURN(0); + return 0; /* No MM (e.g. NFS)? No vmas too. */ if (mm == NULL) - RETURN(0); + return 0; for (seg = 0; seg < vio->cui_nrsegs; seg++) { const struct iovec *iv = &vio->cui_iov[seg]; @@ -234,7 +233,7 @@ static int vvp_mmap_locks(const struct lu_env *env, descr->cld_end); if (result < 0) - RETURN(result); + return result; if (vma->vm_end - addr >= count) break; @@ -244,7 +243,7 @@ static int vvp_mmap_locks(const struct lu_env *env, } up_read(&mm->mmap_sem); } - RETURN(0); + return 0; } static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, @@ -255,7 +254,6 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, int ast_flags = 0; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); - ENTRY; ccc_io_update_iov(env, cio, io); @@ -264,7 +262,7 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, result = vvp_mmap_locks(env, cio, io); if (result == 0) result = ccc_io_one_lock(env, io, ast_flags, mode, start, end); - RETURN(result); + return result; } static int vvp_io_read_lock(const struct lu_env *env, @@ -274,7 +272,6 @@ static int vvp_io_read_lock(const struct lu_env *env, struct ll_inode_info *lli = ll_i2info(ccc_object_inode(io->ci_obj)); int result; - ENTRY; /* XXX: Layer violation, we shouldn't see lsm at llite level. */ if (lli->lli_has_smd) /* lsm-less file doesn't need to lock */ result = vvp_io_rw_lock(env, io, CLM_READ, @@ -283,7 +280,7 @@ static int vvp_io_read_lock(const struct lu_env *env, io->u.ci_rd.rd.crw_count - 1); else result = 0; - RETURN(result); + return result; } static int vvp_io_fault_lock(const struct lu_env *env, @@ -407,13 +404,15 @@ static int vvp_io_setattr_start(const struct lu_env *env, { struct cl_io *io = ios->cis_io; struct inode *inode = ccc_object_inode(io->ci_obj); + int result = 0; mutex_lock(&inode->i_mutex); if (cl_io_is_trunc(io)) - return vvp_io_setattr_trunc(env, ios, inode, - io->u.ci_setattr.sa_attr.lvb_size); - else - return vvp_io_setattr_time(env, ios); + result = vvp_io_setattr_trunc(env, ios, inode, + io->u.ci_setattr.sa_attr.lvb_size); + if (result == 0) + result = vvp_io_setattr_time(env, ios); + return result; } static void vvp_io_setattr_end(const struct lu_env *env, @@ -525,7 +524,7 @@ out: io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, READ); result = 0; } return result; @@ -554,8 +553,6 @@ static int vvp_io_write_start(const struct lu_env *env, loff_t pos = io->u.ci_wr.wr.crw_pos; size_t cnt = io->u.ci_wr.wr.crw_count; - ENTRY; - if (!can_populate_pages(env, io, inode)) return 0; @@ -580,10 +577,10 @@ static int vvp_io_write_start(const struct lu_env *env, io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, WRITE); result = 0; } - RETURN(result); + return result; } static int vvp_io_kernel_fault(struct vvp_fault_io *cfio) @@ -767,7 +764,6 @@ static int vvp_io_fault_start(const struct lu_env *env, lu_ref_add(&page->cp_reference, "fault", io); fio->ft_page = page; - EXIT; out: /* return unlocked vmpage to avoid deadlocking */ @@ -805,8 +801,6 @@ static int vvp_io_read_page(const struct lu_env *env, CLOBINVRNT(env, obj, ccc_object_invariant(obj)); LASSERT(slice->cpl_obj == obj); - ENTRY; - if (sbi->ll_ra_info.ra_max_pages_per_file && sbi->ll_ra_info.ra_max_pages) ras_update(sbi, inode, ras, page->cp_index, @@ -819,7 +813,7 @@ static int vvp_io_read_page(const struct lu_env *env, rc == -ENODATA ? "without a lock" : "match failed", rc); if (rc != -ENODATA) - RETURN(rc); + return rc; } if (cp->cpg_defer_uptodate) { @@ -836,7 +830,7 @@ static int vvp_io_read_page(const struct lu_env *env, ll_readahead(env, io, ras, vmpage->mapping, &queue->c2_qin, fd->fd_flags); - RETURN(0); + return 0; } static int vvp_page_sync_io(const struct lu_env *env, struct cl_io *io, @@ -887,10 +881,10 @@ static int vvp_io_prepare_partial(const struct lu_env *env, struct cl_io *io, * purposes here we can treat it like i_size. */ if (attr->cat_kms <= offset) { - char *kaddr = ll_kmap_atomic(cp->cpg_page, KM_USER0); + char *kaddr = kmap_atomic(cp->cpg_page); memset(kaddr, 0, cl_page_size(obj)); - ll_kunmap_atomic(kaddr, KM_USER0); + kunmap_atomic(kaddr); } else if (cp->cpg_defer_uptodate) cp->cpg_ra_used = 1; else @@ -921,8 +915,6 @@ static int vvp_io_prepare_write(const struct lu_env *env, int result; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == ccc_object_inode(obj)); @@ -942,7 +934,7 @@ static int vvp_io_prepare_write(const struct lu_env *env, pg, cp, from, to); } else CL_PAGE_HEADER(D_PAGE, env, pg, "uptodate\n"); - RETURN(result); + return result; } static int vvp_io_commit_write(const struct lu_env *env, @@ -963,12 +955,10 @@ static int vvp_io_commit_write(const struct lu_env *env, int tallyop; loff_t size; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == inode); - LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "commiting page write\n"); + LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "committing page write\n"); CL_PAGE_HEADER(D_PAGE, env, pg, "committing: [%d, %d]\n", from, to); /* @@ -1067,7 +1057,7 @@ static int vvp_io_commit_write(const struct lu_env *env, cl_page_discard(env, io, pg); } ll_inode_size_unlock(inode); - RETURN(result); + return result; } static const struct cl_io_operations vvp_io_ops = { @@ -1120,7 +1110,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, int result; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - ENTRY; CL_IO_SLICE_CLEAN(cio, cui_cl); cl_io_slice_add(io, &cio->cui_cl, obj, &vvp_io_ops); @@ -1174,7 +1163,7 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, PFID(lu_object_fid(&obj->co_lu)), result); } - RETURN(result); + return result; } static struct vvp_io *cl2vvp_io(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index 9b8712bccd92..e16b31e4ff72 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -63,8 +63,7 @@ static unsigned long vvp_lock_weigh(const struct lu_env *env, { struct ccc_object *cob = cl2ccc(slice->cls_obj); - ENTRY; - RETURN(atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0); + return atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0; } static const struct cl_lock_operations vvp_lock_ops = { diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 01edc5b63e13..33173fce478f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -91,8 +91,8 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj, attr->cat_atime = LTIME_S(inode->i_atime); attr->cat_ctime = LTIME_S(inode->i_ctime); attr->cat_blocks = inode->i_blocks; - attr->cat_uid = inode->i_uid; - attr->cat_gid = inode->i_gid; + attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid); + attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid); /* KMS is not known by this layer */ return 0; /* layers below have to fill in the rest */ } @@ -103,9 +103,9 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj, struct inode *inode = ccc_object_inode(obj); if (valid & CAT_UID) - inode->i_uid = attr->cat_uid; + inode->i_uid = make_kuid(&init_user_ns, attr->cat_uid); if (valid & CAT_GID) - inode->i_gid = attr->cat_gid; + inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid); if (valid & CAT_ATIME) LTIME_S(inode->i_atime) = attr->cat_atime; if (valid & CAT_MTIME) diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 4568e69bb9f0..1c02c128e0ee 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -218,9 +218,8 @@ static int vvp_page_prep_read(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *unused) { - ENTRY; /* Skip the page already marked as PG_uptodate. */ - RETURN(PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0); + return PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0; } static int vvp_page_prep_write(const struct lu_env *env, @@ -274,7 +273,6 @@ static void vvp_page_completion_read(const struct lu_env *env, struct page *vmpage = cp->cpg_page; struct cl_page *page = cl_page_top(slice->cpl_page); struct inode *inode = ccc_object_inode(page->cp_obj); - ENTRY; LASSERT(PageLocked(vmpage)); CL_PAGE_HEADER(D_PAGE, env, page, "completing READ with %d\n", ioret); @@ -290,8 +288,6 @@ static void vvp_page_completion_read(const struct lu_env *env, if (page->cp_sync_io == NULL) unlock_page(vmpage); - - EXIT; } static void vvp_page_completion_write(const struct lu_env *env, @@ -301,7 +297,6 @@ static void vvp_page_completion_write(const struct lu_env *env, struct ccc_page *cp = cl2ccc_page(slice); struct cl_page *pg = slice->cpl_page; struct page *vmpage = cp->cpg_page; - ENTRY; LASSERT(ergo(pg->cp_sync_io != NULL, PageLocked(vmpage))); LASSERT(PageWriteback(vmpage)); @@ -329,7 +324,6 @@ static void vvp_page_completion_write(const struct lu_env *env, vvp_vmpage_error(ccc_object_inode(pg->cp_obj), vmpage, ioret); end_page_writeback(vmpage); - EXIT; } /** @@ -372,7 +366,7 @@ static int vvp_page_make_ready(const struct lu_env *env, LBUG(); } unlock_page(vmpage); - RETURN(result); + return result; } static int vvp_page_print(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 4176264984bb..bcf86bac30a9 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -112,31 +112,32 @@ int ll_setxattr_common(struct inode *inode, const char *name, struct ptlrpc_request *req; int xattr_type, rc; struct obd_capa *oc; +#ifdef CONFIG_FS_POSIX_ACL posix_acl_xattr_header *new_value = NULL; struct rmtacl_ctl_entry *rce = NULL; ext_acl_xattr_header *acl = NULL; +#endif const char *pv = value; - ENTRY; xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b10667: ignore lustre special xattr for now */ if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) || (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0)) - RETURN(0); + return 0; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(0); + return 0; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -146,7 +147,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, if (rce == NULL || (rce->rce_ops != RMT_LSETFACL && rce->rce_ops != RMT_RSETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (rce->rce_ops == RMT_LSETFACL) { struct eacl_entry *ee; @@ -160,7 +161,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, size, ee->ee_acl); if (IS_ERR(acl)) { ee_free(ee); - RETURN(PTR_ERR(acl)); + return PTR_ERR(acl); } size = CFS_ACL_XATTR_SIZE(\ le32_to_cpu(acl->a_count), \ @@ -173,11 +174,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, (posix_acl_xattr_header *)value, size, &new_value); if (unlikely(size < 0)) - RETURN(size); + return size; pv = (const char *)new_value; } else - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; valid |= rce_ops2valid(rce->rce_ops); } @@ -199,11 +200,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } ptlrpc_req_finished(req); - RETURN(0); + return 0; } int ll_setxattr(struct dentry *dentry, const char *name, @@ -285,7 +286,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, void *xdata; struct obd_capa *oc; struct rmtacl_ctl_entry *rce = NULL; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -302,17 +302,17 @@ int ll_getxattr_common(struct inode *inode, const char *name, xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(-ENODATA); + return -ENODATA; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -324,7 +324,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, rce->rce_ops != RMT_LGETFACL && rce->rce_ops != RMT_RSETFACL && rce->rce_ops != RMT_RGETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } /* posix acl is under protection of LOOKUP lock. when calling to this, @@ -341,14 +341,14 @@ int ll_getxattr_common(struct inode *inode, const char *name, spin_unlock(&lli->lli_lock); if (!acl) - RETURN(-ENODATA); + return -ENODATA; rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); posix_acl_release(acl); - RETURN(rc); + return rc; } if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) - RETURN(-ENODATA); + return -ENODATA; #endif do_getxattr: @@ -363,7 +363,7 @@ do_getxattr: "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -413,7 +413,6 @@ do_getxattr: memcpy(buffer, xdata, body->eadatasize); rc = body->eadatasize; } - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -562,7 +561,12 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) const size_t name_len = sizeof("lov") - 1; const size_t total_len = prefix_len + name_len + 1; - if (buffer && (rc + total_len) <= size) { + if (((rc + total_len) > size) && (buffer != NULL)) { + ptlrpc_req_finished(request); + return -ERANGE; + } + + if (buffer != NULL) { buffer += rc; memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len); memcpy(buffer + prefix_len, "lov", name_len); |