aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/llite/llite_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/llite/llite_lib.c')
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c164
1 files changed, 94 insertions, 70 deletions
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 0367f5a2cfe4..a8bcc51057f1 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -41,6 +41,7 @@
#define DEBUG_SUBSYSTEM S_LLITE
#include <linux/module.h>
+#include <linux/statfs.h>
#include <linux/types.h>
#include <linux/mm.h>
@@ -74,7 +75,7 @@ static struct ll_sb_info *ll_init_sbi(void)
class_uuid_t uuid;
int i;
- OBD_ALLOC(sbi, sizeof(*sbi));
+ sbi = kzalloc(sizeof(*sbi), GFP_NOFS);
if (!sbi)
return NULL;
@@ -162,7 +163,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
struct obd_uuid *uuid;
struct md_op_data *op_data;
struct lustre_md lmd;
- obd_valid valid;
+ u64 valid;
int size, err, checksum;
obd = class_name2obd(md);
@@ -171,12 +172,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
return -EINVAL;
}
- OBD_ALLOC_PTR(data);
- if (data == NULL)
+ data = kzalloc(sizeof(*data), GFP_NOFS);
+ if (!data)
return -ENOMEM;
- OBD_ALLOC_PTR(osfs);
- if (osfs == NULL) {
+ osfs = kzalloc(sizeof(*osfs), GFP_NOFS);
+ if (!osfs) {
OBD_FREE_PTR(data);
return -ENOMEM;
}
@@ -255,10 +256,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"recovery, of which this client is not a "
"part. Please wait for recovery to complete,"
" abort, or time out.\n", md);
- GOTO(out, err);
+ goto out;
} else if (err) {
CERROR("cannot connect to %s: rc = %d\n", md, err);
- GOTO(out, err);
+ goto out;
}
sbi->ll_md_exp->exp_connect_data = *data;
@@ -268,7 +269,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: Can't init metadata layer FID infrastructure, "
"rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err);
- GOTO(out_md, err);
+ goto out_md;
}
/* For mount, we only need fs info from MDT0, and also in DNE, it
@@ -278,7 +279,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_FOR_MDT0);
if (err)
- GOTO(out_md_fid, err);
+ goto out_md_fid;
/* This needs to be after statfs to ensure connect has finished.
* Note that "data" does NOT contain the valid connect reply.
@@ -292,7 +293,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
valid != CLIENT_CONNECT_MDT_REQD) {
char *buf;
- OBD_ALLOC_WAIT(buf, PAGE_CACHE_SIZE);
+ buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
obd_connect_flags2str(buf, PAGE_CACHE_SIZE,
valid ^ CLIENT_CONNECT_MDT_REQD, ",");
LCONSOLE_ERROR_MSG(0x170, "Server %s does not support "
@@ -301,7 +302,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"server or downgrade client.\n",
sbi->ll_md_exp->exp_obd->obd_name, buf);
OBD_FREE(buf, PAGE_CACHE_SIZE);
- GOTO(out_md_fid, err = -EPROTO);
+ err = -EPROTO;
+ goto out_md_fid;
}
size = sizeof(*data);
@@ -310,7 +312,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: Get connect data failed: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err);
- GOTO(out_md_fid, err);
+ goto out_md_fid;
}
LASSERT(osfs->os_bsize);
@@ -391,7 +393,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
obd = class_name2obd(dt);
if (!obd) {
CERROR("DT %s: not setup or attached\n", dt);
- GOTO(out_md_fid, err = -ENODEV);
+ err = -ENODEV;
+ goto out_md_fid;
}
data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION |
@@ -442,11 +445,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
"recovery, of which this client is not a "
"part. Please wait for recovery to "
"complete, abort, or time out.\n", dt);
- GOTO(out_md, err);
+ goto out_md;
} else if (err) {
CERROR("%s: Cannot connect to %s: rc = %d\n",
sbi->ll_dt_exp->exp_obd->obd_name, dt, err);
- GOTO(out_md, err);
+ goto out_md;
}
sbi->ll_dt_exp->exp_connect_data = *data;
@@ -456,7 +459,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: Can't init data layer FID infrastructure, "
"rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, err);
- GOTO(out_dt, err);
+ goto out_dt;
}
mutex_lock(&sbi->ll_lco.lco_lock);
@@ -469,13 +472,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, &oc);
if (err) {
CERROR("cannot mds_connect: rc = %d\n", err);
- GOTO(out_lock_cn_cb, err);
+ goto out_lock_cn_cb;
}
if (!fid_is_sane(&sbi->ll_root_fid)) {
CERROR("%s: Invalid root fid "DFID" during mount\n",
sbi->ll_md_exp->exp_obd->obd_name,
PFID(&sbi->ll_root_fid));
- GOTO(out_lock_cn_cb, err = -EINVAL);
+ err = -EINVAL;
+ goto out_lock_cn_cb;
}
CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
@@ -492,9 +496,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
else if (sbi->ll_flags & LL_SBI_ACL)
valid |= OBD_MD_FLACL;
- OBD_ALLOC_PTR(op_data);
- if (op_data == NULL)
- GOTO(out_lock_cn_cb, err = -ENOMEM);
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
+ if (!op_data) {
+ err = -ENOMEM;
+ goto out_lock_cn_cb;
+ }
op_data->op_fid1 = sbi->ll_root_fid;
op_data->op_mode = 0;
@@ -508,7 +514,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("%s: md_getattr failed for root: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err);
- GOTO(out_lock_cn_cb, err);
+ goto out_lock_cn_cb;
}
err = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp,
@@ -516,7 +522,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (err) {
CERROR("failed to understand root inode md: rc = %d\n", err);
ptlrpc_req_finished(request);
- GOTO(out_lock_cn_cb, err);
+ goto out_lock_cn_cb;
}
LASSERT(fid_is_sane(&sbi->ll_root_fid));
@@ -538,13 +544,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
err = IS_ERR(root) ? PTR_ERR(root) : -EBADF;
root = NULL;
CERROR("lustre_lite: bad iget4 for root\n");
- GOTO(out_root, err);
+ goto out_root;
}
err = ll_close_thread_start(&sbi->ll_lcq);
if (err) {
CERROR("cannot start close thread: rc %d\n", err);
- GOTO(out_root, err);
+ goto out_root;
}
#ifdef CONFIG_FS_POSIX_ACL
@@ -568,7 +574,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (sb->s_root == NULL) {
CERROR("%s: can't make root dentry\n",
ll_get_fsname(sb, NULL, 0));
- GOTO(out_root, err = -ENOMEM);
+ err = -ENOMEM;
+ goto out_lock_cn_cb;
}
sbi->ll_sdev_orig = sb->s_dev;
@@ -761,9 +768,9 @@ void ll_kill_super(struct super_block *sb)
static inline int ll_set_opt(const char *opt, char *data, int fl)
{
if (strncmp(opt, data, strlen(opt)) != 0)
- return(0);
+ return 0;
else
- return(fl);
+ return fl;
}
/* non-client-specific mount options are parsed in lmd_parse */
@@ -986,8 +993,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
- OBD_ALLOC_PTR(cfg);
- if (cfg == NULL)
+ cfg = kzalloc(sizeof(*cfg), GFP_NOFS);
+ if (!cfg)
return -ENOMEM;
try_module_get(THIS_MODULE);
@@ -1002,16 +1009,16 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags);
if (err)
- GOTO(out_free, err);
+ goto out_free;
err = bdi_init(&lsi->lsi_bdi);
if (err)
- GOTO(out_free, err);
+ goto out_free;
lsi->lsi_flags |= LSI_BDI_INITIALIZED;
lsi->lsi_bdi.capabilities = BDI_CAP_MAP_COPY;
err = ll_bdi_register(&lsi->lsi_bdi);
if (err)
- GOTO(out_free, err);
+ goto out_free;
sb->s_bdi = &lsi->lsi_bdi;
/* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
@@ -1027,7 +1034,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = lustre_process_log(sb, profilenm, cfg);
if (err < 0) {
CERROR("Unable to process log: %d\n", err);
- GOTO(out_free, err);
+ goto out_free;
}
/* Profile set with LCFG_MOUNTOPT so we can find our mdc and osc obds */
@@ -1036,19 +1043,24 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
LCONSOLE_ERROR_MSG(0x156, "The client profile '%s' could not be"
" read from the MGS. Does that filesystem "
"exist?\n", profilenm);
- GOTO(out_free, err = -EINVAL);
+ err = -EINVAL;
+ goto out_free;
}
CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_md, lprof->lp_dt);
- OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2);
- if (!dt)
- GOTO(out_free, err = -ENOMEM);
+ dt = kzalloc(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS);
+ if (!dt) {
+ err = -ENOMEM;
+ goto out_free;
+ }
sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
- OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2);
- if (!md)
- GOTO(out_free, err = -ENOMEM);
+ md = kzalloc(strlen(lprof->lp_md) + instlen + 2, GFP_NOFS);
+ if (!md) {
+ err = -ENOMEM;
+ goto out_free;
+ }
sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
/* connections, registrations, sb setup */
@@ -1139,7 +1151,7 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock)
/* NOTE: we depend on atomic igrab() -bzzz */
lock_res_and_lock(lock);
if (lock->l_resource->lr_lvb_inode) {
- struct ll_inode_info * lli;
+ struct ll_inode_info *lli;
lli = ll_i2info(lock->l_resource->lr_lvb_inode);
if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
inode = igrab(lock->l_resource->lr_lvb_inode);
@@ -1225,7 +1237,7 @@ void ll_clear_inode(struct inode *inode)
lli->lli_has_smd = false;
}
-int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
+static int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data,
struct md_open_data **mod)
{
struct lustre_md md;
@@ -1377,7 +1389,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
* OST maximum object size and number of stripes. This
* needs another check in addition to the VFS check above. */
if (attr->ia_size > ll_file_maxbytes(inode)) {
- CDEBUG(D_INODE,"file "DFID" too large %llu > %llu\n",
+ CDEBUG(D_INODE, "file "DFID" too large %llu > %llu\n",
PFID(&lli->lli_fid), attr->ia_size,
ll_file_maxbytes(inode));
return -EFBIG;
@@ -1425,8 +1437,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
/* We always do an MDS RPC, even if we're only changing the size;
* only the MDS knows whether truncate() should fail with -ETXTBUSY */
- OBD_ALLOC_PTR(op_data);
- if (op_data == NULL)
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
+ if (!op_data)
return -ENOMEM;
if (!S_ISDIR(inode->i_mode)) {
@@ -1466,14 +1478,15 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
rc = ll_md_setattr(dentry, op_data, &mod);
if (rc)
- GOTO(out, rc);
+ goto out;
/* truncate failed (only when non HSM import), others succeed */
if (file_is_released) {
if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
- GOTO(out, rc = -ENODATA);
+ rc = -ENODATA;
else
- GOTO(out, rc = 0);
+ rc = 0;
+ goto out;
}
/* RPC to MDT is sent, cancel data modification flag */
@@ -1484,8 +1497,10 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
}
ll_ioepoch_open(lli, op_data->op_ioepoch);
- if (!S_ISREG(inode->i_mode))
- GOTO(out, rc = 0);
+ if (!S_ISREG(inode->i_mode)) {
+ rc = 0;
+ goto out;
+ }
if (attr->ia_valid & (ATTR_SIZE |
ATTR_ATIME | ATTR_ATIME_SET |
@@ -1568,7 +1583,8 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
osfs->os_type = sb->s_magic;
CDEBUG(D_SUPER, "MDC blocks %llu/%llu objects %llu/%llu\n",
- osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
+ osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,
+ osfs->os_files);
if (sbi->ll_flags & LL_SBI_LAZYSTATFS)
flags |= OBD_STATFS_NODELAY;
@@ -1885,7 +1901,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
struct ptlrpc_request *req = NULL;
int rc, flags = 0;
- switch(cmd) {
+ switch (cmd) {
case FSFILT_IOC_GETFLAGS: {
struct mdt_body *body;
struct md_op_data *op_data;
@@ -2013,7 +2029,7 @@ void ll_umount_begin(struct super_block *sb)
}
obd->obd_force = 1;
- OBD_ALLOC_PTR(ioc_data);
+ ioc_data = kzalloc(sizeof(*ioc_data), GFP_NOFS);
if (ioc_data) {
obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
sizeof(*ioc_data), ioc_data, NULL);
@@ -2101,7 +2117,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
rc = IS_ERR(*inode) ? PTR_ERR(*inode) : -ENOMEM;
*inode = NULL;
CERROR("new_inode -fatal: rc %d\n", rc);
- GOTO(out, rc);
+ goto out;
}
}
@@ -2150,36 +2166,44 @@ int ll_obd_statfs(struct inode *inode, void *arg)
__u32 flags;
int len = 0, rc;
- if (!inode || !(sbi = ll_i2sbi(inode)))
- GOTO(out_statfs, rc = -EINVAL);
+ if (!inode || !(sbi = ll_i2sbi(inode))) {
+ rc = -EINVAL;
+ goto out_statfs;
+ }
rc = obd_ioctl_getdata(&buf, &len, arg);
if (rc)
- GOTO(out_statfs, rc);
+ goto out_statfs;
- data = (void*)buf;
+ data = (void *)buf;
if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
- !data->ioc_pbuf1 || !data->ioc_pbuf2)
- GOTO(out_statfs, rc = -EINVAL);
+ !data->ioc_pbuf1 || !data->ioc_pbuf2) {
+ rc = -EINVAL;
+ goto out_statfs;
+ }
if (data->ioc_inllen1 != sizeof(__u32) ||
data->ioc_inllen2 != sizeof(__u32) ||
data->ioc_plen1 != sizeof(struct obd_statfs) ||
- data->ioc_plen2 != sizeof(struct obd_uuid))
- GOTO(out_statfs, rc = -EINVAL);
+ data->ioc_plen2 != sizeof(struct obd_uuid)) {
+ rc = -EINVAL;
+ goto out_statfs;
+ }
memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
if (type & LL_STATFS_LMV)
exp = sbi->ll_md_exp;
else if (type & LL_STATFS_LOV)
exp = sbi->ll_dt_exp;
- else
- GOTO(out_statfs, rc = -ENODEV);
+ else {
+ rc = -ENODEV;
+ goto out_statfs;
+ }
flags = (type & LL_STATFS_NODELAY) ? OBD_STATFS_NODELAY : 0;
rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, &flags);
if (rc)
- GOTO(out_statfs, rc);
+ goto out_statfs;
out_statfs:
if (buf)
obd_ioctl_freedata(buf, len);
@@ -2212,11 +2236,11 @@ int ll_process_config(struct lustre_cfg *lcfg)
lcfg, sb);
if (rc > 0)
rc = 0;
- return(rc);
+ return rc;
}
/* this function prepares md_op_data hint for passing ot down to MD stack. */
-struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
+struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
struct inode *i1, struct inode *i2,
const char *name, int namelen,
int mode, __u32 opc, void *data)
@@ -2227,7 +2251,7 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data,
return ERR_PTR(-ENAMETOOLONG);
if (op_data == NULL)
- OBD_ALLOC_PTR(op_data);
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL)
return ERR_PTR(-ENOMEM);