aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/osc/osc_request.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/osc/osc_request.c')
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_request.c339
1 files changed, 192 insertions, 147 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 7034f0a942c5..74805f1ae888 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -104,7 +104,6 @@ struct osc_enqueue_args {
static void osc_release_ppga(struct brw_page **ppga, u32 count);
static int brw_interpret(const struct lu_env *env,
struct ptlrpc_request *req, void *data, int rc);
-static int osc_cleanup(struct obd_device *obd);
/* Pack OSC object metadata for disk storage (LE byte order). */
static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
@@ -113,18 +112,18 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
int lmm_size;
lmm_size = sizeof(**lmmp);
- if (lmmp == NULL)
+ if (!lmmp)
return lmm_size;
- if (*lmmp != NULL && lsm == NULL) {
+ if (*lmmp && !lsm) {
kfree(*lmmp);
*lmmp = NULL;
return 0;
- } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) {
+ } else if (unlikely(lsm && ostid_id(&lsm->lsm_oi) == 0)) {
return -EBADF;
}
- if (*lmmp == NULL) {
+ if (!*lmmp) {
*lmmp = kzalloc(lmm_size, GFP_NOFS);
if (!*lmmp)
return -ENOMEM;
@@ -143,7 +142,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
int lsm_size;
struct obd_import *imp = class_exp2cliimp(exp);
- if (lmm != NULL) {
+ if (lmm) {
if (lmm_bytes < sizeof(*lmm)) {
CERROR("%s: lov_mds_md too small: %d, need %d\n",
exp->exp_obd->obd_name, lmm_bytes,
@@ -160,23 +159,23 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
}
lsm_size = lov_stripe_md_size(1);
- if (lsmp == NULL)
+ if (!lsmp)
return lsm_size;
- if (*lsmp != NULL && lmm == NULL) {
+ if (*lsmp && !lmm) {
kfree((*lsmp)->lsm_oinfo[0]);
kfree(*lsmp);
*lsmp = NULL;
return 0;
}
- if (*lsmp == NULL) {
+ if (!*lsmp) {
*lsmp = kzalloc(lsm_size, GFP_NOFS);
- if (unlikely(*lsmp == NULL))
+ if (unlikely(!*lsmp))
return -ENOMEM;
(*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo),
GFP_NOFS);
- if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) {
+ if (unlikely(!(*lsmp)->lsm_oinfo[0])) {
kfree(*lsmp);
return -ENOMEM;
}
@@ -185,11 +184,11 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return -EBADF;
}
- if (lmm != NULL)
+ if (lmm)
/* XXX zero *lsmp? */
ostid_le_to_cpu(&lmm->lmm_oi, &(*lsmp)->lsm_oi);
- if (imp != NULL &&
+ if (imp &&
(imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_MAXBYTES))
(*lsmp)->lsm_maxbytes = imp->imp_connect_data.ocd_maxbytes;
else
@@ -246,7 +245,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR);
@@ -276,7 +275,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR);
@@ -294,7 +293,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EPROTO;
goto out;
}
@@ -321,7 +320,7 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP);
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR);
@@ -339,7 +338,7 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EPROTO;
goto out;
}
@@ -362,7 +361,7 @@ static int osc_setattr_interpret(const struct lu_env *env,
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EPROTO;
goto out;
}
@@ -384,7 +383,7 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo,
int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR);
@@ -451,7 +450,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa,
}
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto out;
}
@@ -482,7 +481,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa,
goto out_req;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
rc = -EPROTO;
goto out_req;
}
@@ -500,7 +499,7 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa,
lsm->lsm_oi = oa->o_oi;
*ea = lsm;
- if (oti != NULL) {
+ if (oti) {
oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
if (oa->o_valid & OBD_MD_FLCOOKIE) {
@@ -530,7 +529,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo,
int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH);
@@ -573,7 +572,7 @@ static int osc_sync_interpret(const struct lu_env *env,
goto out;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
CERROR("can't unpack ost_body\n");
rc = -EPROTO;
goto out;
@@ -595,7 +594,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
int rc;
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC);
@@ -629,10 +628,11 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo,
/* Find and cancel locally locks matched by @mode in the resource found by
* @objid. Found locks are added into @cancel list. Returns the amount of
- * locks added to @cancels list. */
+ * locks added to @cancels list.
+ */
static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
struct list_head *cancels,
- ldlm_mode_t mode, __u64 lock_flags)
+ enum ldlm_mode mode, __u64 lock_flags)
{
struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
struct ldlm_res_id res_id;
@@ -644,13 +644,14 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
*
* This distinguishes from a case when ELC is not supported originally,
* when we still want to cancel locks in advance and just cancel them
- * locally, without sending any RPC. */
+ * locally, without sending any RPC.
+ */
if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns))
return 0;
ostid_build_res_name(&oa->o_oi, &res_id);
res = ldlm_resource_get(ns, NULL, &res_id, 0, 0);
- if (res == NULL)
+ if (!res)
return 0;
LDLM_RESOURCE_ADDREF(res);
@@ -723,7 +724,8 @@ static int osc_create(const struct lu_env *env, struct obd_export *exp,
* If the client dies, or the OST is down when the object should be destroyed,
* the records are not cancelled, and when the OST reconnects to the MDS next,
* it will retrieve the llog unlink logs and then sends the log cancellation
- * cookies to the MDS after committing destroy transactions. */
+ * cookies to the MDS after committing destroy transactions.
+ */
static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
struct obdo *oa, struct lov_stripe_md *ea,
struct obd_trans_info *oti, struct obd_export *md_export)
@@ -743,7 +745,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
LDLM_FL_DISCARD_DATA);
req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_DESTROY);
- if (req == NULL) {
+ if (!req) {
ldlm_lock_list_put(&cancels, l_bl_ast, count);
return -ENOMEM;
}
@@ -758,7 +760,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */
ptlrpc_at_set_req_timeout(req);
- if (oti != NULL && oa->o_valid & OBD_MD_FLCOOKIE)
+ if (oti && oa->o_valid & OBD_MD_FLCOOKIE)
oa->o_lcookie = *oti->oti_logcookies;
body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
LASSERT(body);
@@ -769,7 +771,8 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
/* If osc_destroy is for destroying the unlink orphan,
* sent from MDT to OST, which should not be blocked here,
* because the process might be triggered by ptlrpcd, and
- * it is not good to block ptlrpcd thread (b=16006)*/
+ * it is not good to block ptlrpcd thread (b=16006
+ **/
if (!(oa->o_flags & OBD_FL_DELORPHAN)) {
req->rq_interpret_reply = osc_destroy_interpret;
if (!osc_can_send_destroy(cli)) {
@@ -810,7 +813,8 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
(long)(obd_max_dirty_pages + 1))) {
/* The atomic_read() allowing the atomic_inc() are
* not covered by a lock thus they may safely race and trip
- * this CERROR() unless we add in a small fudge factor (+1). */
+ * this CERROR() unless we add in a small fudge factor (+1).
+ */
CERROR("dirty %d - %d > system dirty_max %d\n",
atomic_read(&obd_dirty_pages),
atomic_read(&obd_dirty_transit_pages),
@@ -839,7 +843,7 @@ void osc_update_next_shrink(struct client_obd *cli)
{
cli->cl_next_shrink_grant =
cfs_time_shift(cli->cl_grant_shrink_interval);
- CDEBUG(D_CACHE, "next time %ld to shrink grant \n",
+ CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
cli->cl_next_shrink_grant);
}
@@ -900,7 +904,8 @@ static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa)
/* Shrink the current grant, either from some large amount to enough for a
* full set of in-flight RPCs, or if we have already shrunk to that limit
* then to enough for a single RPC. This avoids keeping more grant than
- * needed, and avoids shrinking the grant piecemeal. */
+ * needed, and avoids shrinking the grant piecemeal.
+ */
static int osc_shrink_grant(struct client_obd *cli)
{
__u64 target_bytes = (cli->cl_max_rpcs_in_flight + 1) *
@@ -922,7 +927,8 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
client_obd_list_lock(&cli->cl_loi_list_lock);
/* Don't shrink if we are already above or below the desired limit
* We don't want to shrink below a single RPC, as that will negatively
- * impact block allocation and long-term performance. */
+ * impact block allocation and long-term performance.
+ */
if (target_bytes < cli->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT)
target_bytes = cli->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT;
@@ -970,7 +976,8 @@ static int osc_should_shrink_grant(struct client_obd *client)
if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
/* Get the current RPC size directly, instead of going via:
* cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
- * Keep comment here so that it can be found by searching. */
+ * Keep comment here so that it can be found by searching.
+ */
int brw_size = client->cl_max_pages_per_rpc << PAGE_CACHE_SHIFT;
if (client->cl_import->imp_state == LUSTRE_IMP_FULL &&
@@ -986,8 +993,7 @@ static int osc_grant_shrink_grant_cb(struct timeout_item *item, void *data)
{
struct client_obd *client;
- list_for_each_entry(client, &item->ti_obd_list,
- cl_grant_shrink_list) {
+ list_for_each_entry(client, &item->ti_obd_list, cl_grant_shrink_list) {
if (osc_should_shrink_grant(client))
osc_shrink_grant(client);
}
@@ -1004,10 +1010,10 @@ static int osc_add_shrink_grant(struct client_obd *client)
&client->cl_grant_shrink_list);
if (rc) {
CERROR("add grant client %s error %d\n",
- client->cl_import->imp_obd->obd_name, rc);
+ client->cl_import->imp_obd->obd_name, rc);
return rc;
}
- CDEBUG(D_CACHE, "add grant client %s \n",
+ CDEBUG(D_CACHE, "add grant client %s\n",
client->cl_import->imp_obd->obd_name);
osc_update_next_shrink(client);
return 0;
@@ -1040,7 +1046,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant,
ocd->ocd_grant, cli->cl_dirty);
/* workaround for servers which do not have the patch from
- * LU-2679 */
+ * LU-2679
+ */
cli->cl_avail_grant = ocd->ocd_grant;
}
@@ -1060,7 +1067,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
/* We assume that the reason this OSC got a short read is because it read
* beyond the end of a stripe file; i.e. lustre is reading a sparse file
* via the LOV, and it _knows_ it's reading inside the file, it's just that
- * this stripe never got written at or beyond this stripe offset yet. */
+ * this stripe never got written at or beyond this stripe offset yet.
+ */
static void handle_short_read(int nob_read, u32 page_count,
struct brw_page **pga)
{
@@ -1106,7 +1114,7 @@ static int check_write_rcs(struct ptlrpc_request *req,
remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS,
sizeof(*remote_rcs) *
niocount);
- if (remote_rcs == NULL) {
+ if (!remote_rcs) {
CDEBUG(D_INFO, "Missing/short RC vector on BRW_WRITE reply\n");
return -EPROTO;
}
@@ -1118,7 +1126,7 @@ static int check_write_rcs(struct ptlrpc_request *req,
if (remote_rcs[i] != 0) {
CDEBUG(D_INFO, "rc[%d] invalid (%d) req %p\n",
- i, remote_rcs[i], req);
+ i, remote_rcs[i], req);
return -EPROTO;
}
}
@@ -1139,7 +1147,8 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
OBD_BRW_SYNC | OBD_BRW_ASYNC|OBD_BRW_NOQUOTA);
/* warn if we try to combine flags that we don't know to be
- * safe to combine */
+ * safe to combine
+ */
if (unlikely((p1->flag & mask) != (p2->flag & mask))) {
CWARN("Saw flags 0x%x and 0x%x in the same brw, please report this at http://bugs.whamcloud.com/\n",
p1->flag, p2->flag);
@@ -1152,7 +1161,7 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
static u32 osc_checksum_bulk(int nob, u32 pg_count,
struct brw_page **pga, int opc,
- cksum_type_t cksum_type)
+ enum cksum_type cksum_type)
{
__u32 cksum;
int i = 0;
@@ -1174,7 +1183,8 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count,
int count = pga[i]->count > nob ? nob : pga[i]->count;
/* corrupt the data before we compute the checksum, to
- * simulate an OST->client data error */
+ * simulate an OST->client data error
+ */
if (i == 0 && opc == OST_READ &&
OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE)) {
unsigned char *ptr = kmap(pga[i]->pg);
@@ -1184,7 +1194,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count,
kunmap(pga[i]->pg);
}
cfs_crypto_hash_update_page(hdesc, pga[i]->pg,
- pga[i]->off & ~CFS_PAGE_MASK,
+ pga[i]->off & ~CFS_PAGE_MASK,
count);
CDEBUG(D_PAGE,
"page %p map %p index %lu flags %lx count %u priv %0lx: off %d\n",
@@ -1205,7 +1215,8 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count,
cfs_crypto_hash_final(hdesc, NULL, NULL);
/* For sending we only compute the wrong checksum instead
- * of corrupting the data so it is still correct on a redo */
+ * of corrupting the data so it is still correct on a redo
+ */
if (opc == OST_WRITE && OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_SEND))
cksum++;
@@ -1244,7 +1255,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
opc = OST_READ;
req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_BRW_READ);
}
- if (req == NULL)
+ if (!req)
return -ENOMEM;
for (niocount = i = 1; i < page_count; i++) {
@@ -1266,7 +1277,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */
ptlrpc_at_set_req_timeout(req);
/* ask ptlrpc not to resend on EINPROGRESS since BRWs have their own
- * retry logic */
+ * retry logic
+ */
req->rq_no_retry_einprogress = 1;
desc = ptlrpc_prep_bulk_imp(req, page_count,
@@ -1274,7 +1286,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
opc == OST_WRITE ? BULK_GET_SOURCE : BULK_PUT_SINK,
OST_BULK_PORTAL);
- if (desc == NULL) {
+ if (!desc) {
rc = -ENOMEM;
goto out;
}
@@ -1283,7 +1295,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
body = req_capsule_client_get(pill, &RMF_OST_BODY);
ioobj = req_capsule_client_get(pill, &RMF_OBD_IOOBJ);
niobuf = req_capsule_client_get(pill, &RMF_NIOBUF_REMOTE);
- LASSERT(body != NULL && ioobj != NULL && niobuf != NULL);
+ LASSERT(body && ioobj && niobuf);
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
@@ -1293,7 +1305,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
* that might be send for this request. The actual number is decided
* when the RPC is finally sent in ptlrpc_register_bulk(). It sends
* "max - 1" for old client compatibility sending "0", and also so the
- * the actual maximum is a power-of-two number, not one less. LU-1431 */
+ * the actual maximum is a power-of-two number, not one less. LU-1431
+ */
ioobj_max_brw_set(ioobj, desc->bd_md_max_brw);
LASSERT(page_count > 0);
pg_prev = pga[0];
@@ -1355,8 +1368,9 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
if (cli->cl_checksum &&
!sptlrpc_flavor_has_bulk(&req->rq_flvr)) {
/* store cl_cksum_type in a local variable since
- * it can be changed via lprocfs */
- cksum_type_t cksum_type = cli->cl_cksum_type;
+ * it can be changed via lprocfs
+ */
+ enum cksum_type cksum_type = cli->cl_cksum_type;
if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) {
oa->o_flags &= OBD_FL_LOCAL_MASK;
@@ -1375,7 +1389,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
oa->o_flags |= cksum_type_pack(cksum_type);
} else {
/* clear out the checksum flag, in case this is a
- * resend but cl_checksum is no longer set. b=11238 */
+ * resend but cl_checksum is no longer set. b=11238
+ */
oa->o_valid &= ~OBD_MD_FLCKSUM;
}
oa->o_cksum = body->oa.o_cksum;
@@ -1415,11 +1430,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer,
__u32 client_cksum, __u32 server_cksum, int nob,
u32 page_count, struct brw_page **pga,
- cksum_type_t client_cksum_type)
+ enum cksum_type client_cksum_type)
{
__u32 new_cksum;
char *msg;
- cksum_type_t cksum_type;
+ enum cksum_type cksum_type;
if (server_cksum == client_cksum) {
CDEBUG(D_PAGE, "checksum %x confirmed\n", client_cksum);
@@ -1472,9 +1487,9 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
return rc;
}
- LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc);
+ LASSERTF(req->rq_repmsg, "rc = %d\n", rc);
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
- if (body == NULL) {
+ if (!body) {
DEBUG_REQ(D_INFO, req, "Can't unpack body\n");
return -EPROTO;
}
@@ -1538,7 +1553,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
if (rc != req->rq_bulk->bd_nob_transferred) {
CERROR("Unexpected rc %d (%d transferred)\n",
- rc, req->rq_bulk->bd_nob_transferred);
+ rc, req->rq_bulk->bd_nob_transferred);
return -EPROTO;
}
@@ -1550,7 +1565,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
__u32 server_cksum = body->oa.o_cksum;
char *via = "";
char *router = "";
- cksum_type_t cksum_type;
+ enum cksum_type cksum_type;
cksum_type = cksum_type_unpack(body->oa.o_valid&OBD_MD_FLFLAGS ?
body->oa.o_flags : 0);
@@ -1627,7 +1642,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
return rc;
list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) {
- if (oap->oap_request != NULL) {
+ if (oap->oap_request) {
LASSERTF(request == oap->oap_request,
"request %p != oap_request %p\n",
request, oap->oap_request);
@@ -1638,12 +1653,14 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
}
}
/* New request takes over pga and oaps from old request.
- * Note that copying a list_head doesn't work, need to move it... */
+ * Note that copying a list_head doesn't work, need to move it...
+ */
aa->aa_resends++;
new_req->rq_interpret_reply = request->rq_interpret_reply;
new_req->rq_async_args = request->rq_async_args;
/* cap resend delay to the current request timeout, this is similar to
- * what ptlrpc does (see after_reply()) */
+ * what ptlrpc does (see after_reply())
+ */
if (aa->aa_resends > new_req->rq_timeout)
new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout;
else
@@ -1669,7 +1686,8 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
/* XXX: This code will run into problem if we're going to support
* to add a series of BRW RPCs into a self-defined ptlrpc_request_set
* and wait for all of them to be finished. We should inherit request
- * set from old request. */
+ * set from old request.
+ */
ptlrpcd_add_req(new_req);
DEBUG_REQ(D_INFO, new_req, "new request");
@@ -1709,7 +1727,7 @@ static void sort_brw_pages(struct brw_page **array, int num)
static void osc_release_ppga(struct brw_page **ppga, u32 count)
{
- LASSERT(ppga != NULL);
+ LASSERT(ppga);
kfree(ppga);
}
@@ -1725,7 +1743,8 @@ static int brw_interpret(const struct lu_env *env,
rc = osc_brw_fini_request(req, rc);
CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc);
/* When server return -EINPROGRESS, client should always retry
- * regardless of the number of times the bulk was resent already. */
+ * regardless of the number of times the bulk was resent already.
+ */
if (osc_recoverable_error(rc)) {
if (req->rq_import_generation !=
req->rq_import->imp_generation) {
@@ -1748,7 +1767,7 @@ static int brw_interpret(const struct lu_env *env,
}
list_for_each_entry_safe(ext, tmp, &aa->aa_exts, oe_link) {
- if (obj == NULL && rc == 0) {
+ if (!obj && rc == 0) {
obj = osc2cl(ext->oe_obj);
cl_object_get(obj);
}
@@ -1759,7 +1778,7 @@ static int brw_interpret(const struct lu_env *env,
LASSERT(list_empty(&aa->aa_exts));
LASSERT(list_empty(&aa->aa_oaps));
- if (obj != NULL) {
+ if (obj) {
struct obdo *oa = aa->aa_oa;
struct cl_attr *attr = &osc_env_info(env)->oti_attr;
unsigned long valid = 0;
@@ -1798,7 +1817,8 @@ static int brw_interpret(const struct lu_env *env,
client_obd_list_lock(&cli->cl_loi_list_lock);
/* We need to decrement before osc_ap_completion->osc_wake_cache_waiters
* is called so we know whether to go to sync BRWs or wait for more
- * RPCs to complete */
+ * RPCs to complete
+ */
if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE)
cli->cl_w_in_flight--;
else
@@ -1871,13 +1891,13 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
}
pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS);
- if (pga == NULL) {
+ if (!pga) {
rc = -ENOMEM;
goto out;
}
- oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
- if (oa == NULL) {
+ oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
+ if (!oa) {
rc = -ENOMEM;
goto out;
}
@@ -1886,7 +1906,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
list_for_each_entry(oap, &rpc_list, oap_rpc_item) {
struct cl_page *page = oap2cl_page(oap);
- if (clerq == NULL) {
+ if (!clerq) {
clerq = cl_req_alloc(env, page, crt,
1 /* only 1-object rpcs for now */);
if (IS_ERR(clerq)) {
@@ -1907,7 +1927,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
}
/* always get the data for the obdo for the rpc */
- LASSERT(clerq != NULL);
+ LASSERT(clerq);
crattr->cra_oa = oa;
cl_req_attr_set(env, clerq, crattr, ~0ULL);
if (lock) {
@@ -1923,7 +1943,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
sort_brw_pages(pga, page_count);
rc = osc_brw_prep_request(cmd, cli, oa, NULL, page_count,
- pga, &req, 1, 0);
+ pga, &req, 1, 0);
if (rc != 0) {
CERROR("prep_req failed: %d\n", rc);
goto out;
@@ -1938,7 +1958,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
* we race with setattr (locally or in queue at OST). If OST gets
* later setattr before earlier BRW (as determined by the request xid),
* the OST will not use BRW timestamps. Sadly, there is no obvious
- * way to do this in a single call. bug 10150 */
+ * way to do this in a single call. bug 10150
+ */
body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
crattr->cra_oa = &body->oa;
cl_req_attr_set(env, clerq, crattr,
@@ -1955,19 +1976,20 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
aa->aa_clerq = clerq;
/* queued sync pages can be torn down while the pages
- * were between the pending list and the rpc */
+ * were between the pending list and the rpc
+ */
tmp = NULL;
list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) {
/* only one oap gets a request reference */
- if (tmp == NULL)
+ if (!tmp)
tmp = oap;
if (oap->oap_interrupted && !req->rq_intr) {
CDEBUG(D_INODE, "oap %p in req %p interrupted\n",
- oap, req);
+ oap, req);
ptlrpc_mark_interrupted(req);
}
}
- if (tmp != NULL)
+ if (tmp)
tmp->oap_request = ptlrpc_request_addref(req);
client_obd_list_lock(&cli->cl_loi_list_lock);
@@ -2001,16 +2023,17 @@ out:
kfree(crattr);
if (rc != 0) {
- LASSERT(req == NULL);
+ LASSERT(!req);
if (oa)
kmem_cache_free(obdo_cachep, oa);
kfree(pga);
/* this should happen rarely and is pretty bad, it makes the
- * pending list not follow the dirty order */
+ * pending list not follow the dirty order
+ */
while (!list_empty(ext_list)) {
ext = list_entry(ext_list->next, struct osc_extent,
- oe_link);
+ oe_link);
list_del_init(&ext->oe_link);
osc_extent_finish(env, ext, 0, rc);
}
@@ -2026,7 +2049,6 @@ static int osc_set_lock_data_with_check(struct ldlm_lock *lock,
void *data = einfo->ei_cbdata;
int set = 0;
- LASSERT(lock != NULL);
LASSERT(lock->l_blocking_ast == einfo->ei_cb_bl);
LASSERT(lock->l_resource->lr_type == einfo->ei_type);
LASSERT(lock->l_completion_ast == einfo->ei_cb_cp);
@@ -2035,7 +2057,7 @@ static int osc_set_lock_data_with_check(struct ldlm_lock *lock,
lock_res_and_lock(lock);
spin_lock(&osc_ast_guard);
- if (lock->l_ast_data == NULL)
+ if (!lock->l_ast_data)
lock->l_ast_data = data;
if (lock->l_ast_data == data)
set = 1;
@@ -2052,7 +2074,7 @@ static int osc_set_data_with_check(struct lustre_handle *lockh,
struct ldlm_lock *lock = ldlm_handle2lock(lockh);
int set = 0;
- if (lock != NULL) {
+ if (lock) {
set = osc_set_lock_data_with_check(lock, einfo);
LDLM_LOCK_PUT(lock);
} else
@@ -2064,7 +2086,8 @@ static int osc_set_data_with_check(struct lustre_handle *lockh,
/* find any ldlm lock of the inode in osc
* return 0 not find
* 1 find one
- * < 0 error */
+ * < 0 error
+ */
static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
ldlm_iterator_t replace, void *data)
{
@@ -2095,7 +2118,6 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb,
rep = req_capsule_server_get(&req->rq_pill,
&RMF_DLM_REP);
- LASSERT(rep != NULL);
rep->lock_policy_res1 =
ptlrpc_status_ntoh(rep->lock_policy_res1);
if (rep->lock_policy_res1)
@@ -2127,18 +2149,21 @@ static int osc_enqueue_interpret(const struct lu_env *env,
__u64 *flags = aa->oa_flags;
/* Make a local copy of a lock handle and a mode, because aa->oa_*
- * might be freed anytime after lock upcall has been called. */
+ * might be freed anytime after lock upcall has been called.
+ */
lustre_handle_copy(&handle, aa->oa_lockh);
mode = aa->oa_ei->ei_mode;
/* ldlm_cli_enqueue is holding a reference on the lock, so it must
- * be valid. */
+ * be valid.
+ */
lock = ldlm_handle2lock(&handle);
/* Take an additional reference so that a blocking AST that
* ldlm_cli_enqueue_fini() might post for a failed lock, is guaranteed
* to arrive after an upcall has been executed by
- * osc_enqueue_fini(). */
+ * osc_enqueue_fini().
+ */
ldlm_lock_addref(&handle, mode);
/* Let CP AST to grant the lock first. */
@@ -2170,7 +2195,7 @@ static int osc_enqueue_interpret(const struct lu_env *env,
*/
ldlm_lock_decref(&handle, mode);
- LASSERTF(lock != NULL, "lockh %p, req %p, aa %p - client evicted?\n",
+ LASSERTF(lock, "lockh %p, req %p, aa %p - client evicted?\n",
aa->oa_lockh, req, aa);
ldlm_lock_decref(&handle, mode);
LDLM_LOCK_PUT(lock);
@@ -2185,7 +2210,8 @@ struct ptlrpc_request_set *PTLRPCD_SET = (void *)1;
* others may take a considerable amount of time in a case of ost failure; and
* when other sync requests do not get released lock from a client, the client
* is excluded from the cluster -- such scenarious make the life difficult, so
- * release locks just after they are obtained. */
+ * release locks just after they are obtained.
+ */
int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
__u64 *flags, ldlm_policy_data_t *policy,
struct ost_lvb *lvb, int kms_valid,
@@ -2198,11 +2224,12 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
struct ptlrpc_request *req = NULL;
int intent = *flags & LDLM_FL_HAS_INTENT;
__u64 match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY);
- ldlm_mode_t mode;
+ enum ldlm_mode mode;
int rc;
/* Filesystem lock extents are extended to page boundaries so that
- * dealing with the page cache is a little smoother. */
+ * dealing with the page cache is a little smoother.
+ */
policy->l_extent.start -= policy->l_extent.start & ~CFS_PAGE_MASK;
policy->l_extent.end |= ~CFS_PAGE_MASK;
@@ -2226,7 +2253,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
*
* At some point we should cancel the read lock instead of making them
* send us a blocking callback, but there are problems with canceling
- * locks out from other users right now, too. */
+ * locks out from other users right now, too.
+ */
mode = einfo->ei_mode;
if (einfo->ei_mode == LCK_PR)
mode |= LCK_PW;
@@ -2238,7 +2266,8 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
if ((agl != 0) && !(matched->l_flags & LDLM_FL_LVB_READY)) {
/* For AGL, if enqueue RPC is sent but the lock is not
* granted, then skip to process this strpe.
- * Return -ECANCELED to tell the caller. */
+ * Return -ECANCELED to tell the caller.
+ */
ldlm_lock_decref(lockh, mode);
LDLM_LOCK_PUT(matched);
return -ECANCELED;
@@ -2247,19 +2276,22 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
if (osc_set_lock_data_with_check(matched, einfo)) {
*flags |= LDLM_FL_LVB_READY;
/* addref the lock only if not async requests and PW
- * lock is matched whereas we asked for PR. */
+ * lock is matched whereas we asked for PR.
+ */
if (!rqset && einfo->ei_mode != mode)
ldlm_lock_addref(lockh, LCK_PR);
if (intent) {
/* I would like to be able to ASSERT here that
* rss <= kms, but I can't, for reasons which
- * are explained in lov_enqueue() */
+ * are explained in lov_enqueue()
+ */
}
/* We already have a lock, and it's referenced.
*
* At this point, the cl_lock::cll_state is CLS_QUEUING,
- * AGL upcall may change it to CLS_HELD directly. */
+ * AGL upcall may change it to CLS_HELD directly.
+ */
(*upcall)(cookie, ELDLM_OK);
if (einfo->ei_mode != mode)
@@ -2281,7 +2313,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_LDLM_ENQUEUE_LVB);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0);
@@ -2341,27 +2373,29 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id,
{
struct obd_device *obd = exp->exp_obd;
__u64 lflags = *flags;
- ldlm_mode_t rc;
+ enum ldlm_mode rc;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH))
return -EIO;
/* Filesystem lock extents are extended to page boundaries so that
- * dealing with the page cache is a little smoother */
+ * dealing with the page cache is a little smoother
+ */
policy->l_extent.start -= policy->l_extent.start & ~CFS_PAGE_MASK;
policy->l_extent.end |= ~CFS_PAGE_MASK;
/* Next, search for already existing extent locks that will cover us */
/* If we're trying to read, we also search for an existing PW lock. The
* VFS and page cache already protect us locally, so lots of readers/
- * writers can share a single PW lock. */
+ * writers can share a single PW lock.
+ */
rc = mode;
if (mode == LCK_PR)
rc |= LCK_PW;
rc = ldlm_lock_match(obd->obd_namespace, lflags,
res_id, type, policy, rc, lockh, unref);
if (rc) {
- if (data != NULL) {
+ if (data) {
if (!osc_set_data_with_check(lockh, data)) {
if (!(lflags & LDLM_FL_TEST_LOCK))
ldlm_lock_decref(lockh, rc);
@@ -2398,8 +2432,9 @@ static int osc_statfs_interpret(const struct lu_env *env,
* due to issues at a higher level (LOV).
* Exit immediately since the caller is
* aware of the problem and takes care
- * of the clean up */
- return rc;
+ * of the clean up
+ */
+ return rc;
if ((rc == -ENOTCONN || rc == -EAGAIN) &&
(aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) {
@@ -2411,7 +2446,7 @@ static int osc_statfs_interpret(const struct lu_env *env,
goto out;
msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
- if (msfs == NULL) {
+ if (!msfs) {
rc = -EPROTO;
goto out;
}
@@ -2436,9 +2471,10 @@ static int osc_statfs_async(struct obd_export *exp,
* extra calls into the filesystem if that isn't necessary (e.g.
* during mount that would help a bit). Having relative timestamps
* is not so great if request processing is slow, while absolute
- * timestamps are not ideal because they need time synchronization. */
+ * timestamps are not ideal because they need time synchronization.
+ */
req = ptlrpc_request_alloc(obd->u.cli.cl_import, &RQF_OST_STATFS);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS);
@@ -2474,8 +2510,9 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
struct obd_import *imp = NULL;
int rc;
- /*Since the request might also come from lprocfs, so we need
- *sync this with client_disconnect_export Bug15684*/
+ /* Since the request might also come from lprocfs, so we need
+ * sync this with client_disconnect_export Bug15684
+ */
down_read(&obd->u.cli.cl_sem);
if (obd->u.cli.cl_import)
imp = class_import_get(obd->u.cli.cl_import);
@@ -2488,12 +2525,13 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
* extra calls into the filesystem if that isn't necessary (e.g.
* during mount that would help a bit). Having relative timestamps
* is not so great if request processing is slow, while absolute
- * timestamps are not ideal because they need time synchronization. */
+ * timestamps are not ideal because they need time synchronization.
+ */
req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
class_import_put(imp);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS);
@@ -2516,7 +2554,7 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
goto out;
msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
- if (msfs == NULL) {
+ if (!msfs) {
rc = -EPROTO;
goto out;
}
@@ -2534,7 +2572,8 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
* the maximum number of OST indices which will fit in the user buffer.
* lmm_magic must be LOV_MAGIC (we only use 1 slot here).
*/
-static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
+static int osc_getstripe(struct lov_stripe_md *lsm,
+ struct lov_user_md __user *lump)
{
/* we use lov_user_md_v3 because it is larger than lov_user_md_v1 */
struct lov_user_md_v3 lum, *lumk;
@@ -2545,7 +2584,8 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
return -ENODATA;
/* we only need the header part from user space to get lmm_magic and
- * lmm_stripe_count, (the header part is common to v1 and v3) */
+ * lmm_stripe_count, (the header part is common to v1 and v3)
+ */
lum_size = sizeof(struct lov_user_md_v1);
if (copy_from_user(&lum, lump, lum_size))
return -EFAULT;
@@ -2560,7 +2600,8 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lumk->lmm_objects[0]));
/* we can use lov_mds_md_size() to compute lum_size
- * because lov_user_md_vX and lov_mds_md_vX have the same size */
+ * because lov_user_md_vX and lov_mds_md_vX have the same size
+ */
if (lum.lmm_stripe_count > 0) {
lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic);
lumk = kzalloc(lum_size, GFP_NOFS);
@@ -2591,14 +2632,15 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
}
static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
- void *karg, void *uarg)
+ void *karg, void __user *uarg)
{
struct obd_device *obd = exp->exp_obd;
struct obd_ioctl_data *data = karg;
int err = 0;
if (!try_module_get(THIS_MODULE)) {
- CERROR("Can't get module. Is it alive?");
+ CERROR("%s: cannot get module '%s'\n", obd->obd_name,
+ module_name(THIS_MODULE));
return -EINVAL;
}
switch (cmd) {
@@ -2700,7 +2742,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_OST_GET_INFO_LAST_ID);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
@@ -2721,7 +2763,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
goto out;
reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID);
- if (reply == NULL) {
+ if (!reply) {
rc = -EPROTO;
goto out;
}
@@ -2735,7 +2777,7 @@ out:
struct ldlm_res_id res_id;
ldlm_policy_data_t policy;
struct lustre_handle lockh;
- ldlm_mode_t mode = 0;
+ enum ldlm_mode mode = 0;
struct ptlrpc_request *req;
struct ll_user_fiemap *reply;
char *tmp;
@@ -2774,7 +2816,7 @@ out:
skip_locking:
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
&RQF_OST_GET_INFO_FIEMAP);
- if (req == NULL) {
+ if (!req) {
rc = -ENOMEM;
goto drop_lock;
}
@@ -2803,7 +2845,7 @@ skip_locking:
goto fini_req;
reply = req_capsule_server_get(&req->rq_pill, &RMF_FIEMAP_VAL);
- if (reply == NULL) {
+ if (!reply) {
rc = -EPROTO;
goto fini_req;
}
@@ -2852,7 +2894,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
if (KEY_IS(KEY_CACHE_SET)) {
struct client_obd *cli = &obd->u.cli;
- LASSERT(cli->cl_cache == NULL); /* only once */
+ LASSERT(!cli->cl_cache); /* only once */
cli->cl_cache = val;
atomic_inc(&cli->cl_cache->ccc_users);
cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
@@ -2880,16 +2922,17 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
return -EINVAL;
/* We pass all other commands directly to OST. Since nobody calls osc
- methods directly and everybody is supposed to go through LOV, we
- assume lov checked invalid values for us.
- The only recognised values so far are evict_by_nid and mds_conn.
- Even if something bad goes through, we'd get a -EINVAL from OST
- anyway. */
+ * methods directly and everybody is supposed to go through LOV, we
+ * assume lov checked invalid values for us.
+ * The only recognised values so far are evict_by_nid and mds_conn.
+ * Even if something bad goes through, we'd get a -EINVAL from OST
+ * anyway.
+ */
req = ptlrpc_request_alloc(imp, KEY_IS(KEY_GRANT_SHRINK) ?
&RQF_OST_SET_GRANT_INFO :
&RQF_OBD_SET_INFO);
- if (req == NULL)
+ if (!req)
return -ENOMEM;
req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
@@ -2916,7 +2959,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
aa = ptlrpc_req_async_args(req);
- oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO);
+ oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
if (!oa) {
ptlrpc_req_finished(req);
return -ENOMEM;
@@ -2928,7 +2971,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
ptlrpc_request_set_replen(req);
if (!KEY_IS(KEY_GRANT_SHRINK)) {
- LASSERT(set != NULL);
+ LASSERT(set);
ptlrpc_set_add_req(set, req);
ptlrpc_check_set(NULL, set);
} else {
@@ -2946,7 +2989,7 @@ static int osc_reconnect(const struct lu_env *env,
{
struct client_obd *cli = &obd->u.cli;
- if (data != NULL && (data->ocd_connect_flags & OBD_CONNECT_GRANT)) {
+ if (data && (data->ocd_connect_flags & OBD_CONNECT_GRANT)) {
long lost_grant;
client_obd_list_lock(&cli->cl_loi_list_lock);
@@ -2987,7 +3030,7 @@ static int osc_disconnect(struct obd_export *exp)
* So the osc should be disconnected from the shrink list, after we
* are sure the import has been destroyed. BUG18662
*/
- if (obd->u.cli.cl_import == NULL)
+ if (!obd->u.cli.cl_import)
osc_del_shrink_grant(&obd->u.cli);
return rc;
}
@@ -3024,7 +3067,8 @@ static int osc_import_event(struct obd_device *obd,
/* Reset grants */
cli = &obd->u.cli;
/* all pages go to failing rpcs due to the invalid
- * import */
+ * import
+ */
osc_io_unplug(env, cli, NULL);
ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
@@ -3206,13 +3250,13 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
return 0;
}
-int osc_cleanup(struct obd_device *obd)
+static int osc_cleanup(struct obd_device *obd)
{
struct client_obd *cli = &obd->u.cli;
int rc;
/* lru cleanup */
- if (cli->cl_cache != NULL) {
+ if (cli->cl_cache) {
LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0);
spin_lock(&cli->cl_cache->ccc_lru_lock);
list_del_init(&cli->cl_lru_osc);
@@ -3255,7 +3299,7 @@ static int osc_process_config(struct obd_device *obd, u32 len, void *buf)
return osc_process_config_base(obd, buf);
}
-struct obd_ops osc_obd_ops = {
+static struct obd_ops osc_obd_ops = {
.owner = THIS_MODULE,
.setup = osc_setup,
.precleanup = osc_precleanup,
@@ -3298,7 +3342,8 @@ static int __init osc_init(void)
/* print an address of _any_ initialized kernel symbol from this
* module, to allow debugging with gdb that doesn't support data
- * symbols from modules.*/
+ * symbols from modules.
+ */
CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches);
rc = lu_kmem_init(osc_caches);