From: zhanghc Date: Wed, 10 Jun 2009 17:22:37 +0000 (+0000) Subject: b=18364 X-Git-Tag: v1_9_220~160 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c63852e37c8992cbf84eb972711bddb3c5eb7c7f b=18364 1, add initialized code for local obdo variables 2, move OBD_FL_* flags definition into an enum structure i=adilger@sun.com i=johann@sun.com --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index abac33c..9a35643 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -42,7 +42,6 @@ #ifndef _LPROCFS_SNMP_H #define _LPROCFS_SNMP_H -#include #if defined(__linux__) #include #elif defined(__APPLE__) @@ -52,6 +51,7 @@ #else #error Unsupported operating system. #endif +#include #undef LPROCFS #if (defined(__KERNEL__) && defined(CONFIG_PROC_FS)) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 7f81dd4..79fb1f7 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -884,26 +884,32 @@ typedef __u32 obd_gid; typedef __u32 obd_flag; typedef __u32 obd_count; -#define OBD_FL_INLINEDATA (0x00000001) -#define OBD_FL_OBDMDEXISTS (0x00000002) -#define OBD_FL_DELORPHAN (0x00000004) /* if set in o_flags delete orphans */ -#define OBD_FL_NORPC (0x00000008) /* set in o_flags do in OSC not OST */ -#define OBD_FL_IDONLY (0x00000010) /* set in o_flags only adjust obj id*/ -#define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */ -#define OBD_FL_DEBUG_CHECK (0x00000040) /* echo client/server debug check */ -#define OBD_FL_NO_USRQUOTA (0x00000100) /* the object's owner is over quota */ -#define OBD_FL_NO_GRPQUOTA (0x00000200) /* the object's group is over quota */ -#define OBD_FL_CREATE_CROW (0x00000400) /* object should be create on write */ - -#define OBD_FL_TRUNCLOCK (0x00000800) /* delegate DLM locking during punch */ -#define OBD_FL_CKSUM_CRC32 (0x00001000) /* CRC32 checksum type */ -#define OBD_FL_CKSUM_ADLER (0x00002000) /* ADLER checksum type */ -#define OBD_FL_CKSUM_RESV1 (0x00004000) /* reserved for future checksum type */ -#define OBD_FL_CKSUM_RESV2 (0x00008000) /* reserved for future checksum type */ -#define OBD_FL_CKSUM_RESV3 (0x00010000) /* reserved for future checksum type */ -#define OBD_FL_SHRINK_GRANT (0x00020000) /* object shrink the grant */ - -#define OBD_FL_CKSUM_ALL (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER) +enum obdo_flags { + OBD_FL_INLINEDATA = 0x00000001, + OBD_FL_OBDMDEXISTS = 0x00000002, + OBD_FL_DELORPHAN = 0x00000004, /* if set in o_flags delete orphans */ + OBD_FL_NORPC = 0x00000008, /* set in o_flags do in OSC not OST */ + OBD_FL_IDONLY = 0x00000010, /* set in o_flags only adjust obj id*/ + OBD_FL_RECREATE_OBJS= 0x00000020, /* recreate missing obj */ + OBD_FL_DEBUG_CHECK = 0x00000040, /* echo client/server debug check */ + OBD_FL_NO_USRQUOTA = 0x00000100, /* the object's owner is over quota */ + OBD_FL_NO_GRPQUOTA = 0x00000200, /* the object's group is over quota */ + OBD_FL_CREATE_CROW = 0x00000400, /* object should be create on write */ + OBD_FL_TRUNCLOCK = 0x00000800, /* delegate DLM locking during punch*/ + OBD_FL_CKSUM_CRC32 = 0x00001000, /* CRC32 checksum type */ + OBD_FL_CKSUM_ADLER = 0x00002000, /* ADLER checksum type */ + OBD_FL_CKSUM_RSVD1 = 0x00004000, /* for future cksum types */ + OBD_FL_CKSUM_RSVD2 = 0x00008000, /* for future cksum types */ + OBD_FL_CKSUM_RSVD3 = 0x00010000, /* for future cksum types */ + OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */ + + OBD_FL_CKSUM_ALL = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER, + + /* mask for local-only flag, which won't be sent over network */ + OBD_FL_LOCAL_MASK = 0xF0000000, + /* temporary OBDO used by osc_brw_async (see bug 18364) */ + OBD_FL_TEMPORARY = 0x10000000, +}; #define LOV_MAGIC_V1 0x0BD10BD0 #define LOV_MAGIC LOV_MAGIC_V1 @@ -2549,6 +2555,23 @@ struct obdo { #define o_dropped o_misc #define o_cksum o_nlink +static inline void lustre_set_wire_obdo(struct obdo *wobdo, struct obdo *lobdo) +{ + memcpy(wobdo, lobdo, sizeof(*lobdo)); + wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; +} + +static inline void lustre_get_wire_obdo(struct obdo *lobdo, struct obdo *wobdo) +{ + obd_flag local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; + + LASSERT(!(wobdo->o_flags & OBD_FL_LOCAL_MASK)); + + memcpy(lobdo, wobdo, sizeof(*lobdo)); + lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + lobdo->o_flags |= local_flags; +} + extern void lustre_swab_obdo (struct obdo *o); /* request structure for OST's */ diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h index 743ce3b..f284bab 100644 --- a/lustre/include/lustre_export.h +++ b/lustre/include/lustre_export.h @@ -37,9 +37,9 @@ #ifndef __EXPORT_H #define __EXPORT_H +#include #include #include -#include #include struct mds_client_data; diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 85b0195..9c6cd5d 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -47,8 +47,8 @@ #error Unsupported operating system. #endif -#include #include +#include #include #include #include diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index 1850fd3..545a216 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -346,7 +346,7 @@ int llu_sizeonmds_update(struct inode *inode, struct lustre_handle *fh, struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); struct md_op_data op_data = {{ 0 }}; - struct obdo oa; + struct obdo oa = { 0 }; int rc; ENTRY; diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index d62321c..48b753e 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -39,8 +39,8 @@ # include # include #endif -#include #include +#include #include "mdc_internal.h" #ifndef __KERNEL__ diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 8c0de10..c7a0f80 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -460,7 +460,7 @@ out: int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid) { int rc; - struct obdo oa; + struct obdo oa = { 0 }; struct obd_trans_info oti = {0}; struct lov_stripe_md *empty_ea = NULL; ENTRY; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 1fdd3b4..5553323 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3558,7 +3558,7 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa, struct filter_obd *filter) { - struct obdo doa; /* XXX obdo on stack */ + struct obdo doa = { 0 }; /* XXX obdo on stack */ obd_id last, id; int rc = 0; int skip_orphan; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 77e6db5..9f3a6c4 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -185,7 +185,7 @@ static inline void osc_pack_req_body(struct ptlrpc_request *req, body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - body->oa = *oinfo->oi_oa; + lustre_set_wire_obdo(&body->oa, oinfo->oi_oa); osc_pack_capa(req, body, oinfo->oi_capa); } @@ -214,7 +214,7 @@ static int osc_getattr_interpret(const struct lu_env *env, lustre_swab_ost_body); if (body) { CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); - memcpy(aa->aa_oi->oi_oa, &body->oa, sizeof(*aa->aa_oi->oi_oa)); + lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa); /* This should really be sent by the OST */ aa->aa_oi->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE; @@ -292,7 +292,7 @@ static int osc_getattr(struct obd_export *exp, struct obd_info *oinfo) GOTO(out, rc = -EPROTO); CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); - *oinfo->oi_oa = body->oa; + lustre_get_wire_obdo(oinfo->oi_oa, &body->oa); /* This should really be sent by the OST */ oinfo->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE; @@ -340,7 +340,7 @@ static int osc_setattr(struct obd_export *exp, struct obd_info *oinfo, if (body == NULL) GOTO(out, rc = -EPROTO); - *oinfo->oi_oa = body->oa; + lustre_get_wire_obdo(oinfo->oi_oa, &body->oa); EXIT; out: @@ -362,7 +362,7 @@ static int osc_setattr_interpret(const struct lu_env *env, if (body == NULL) GOTO(out, rc = -EPROTO); - *aa->aa_oi->oi_oa = body->oa; + lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa); out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); RETURN(rc); @@ -446,7 +446,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - body->oa = *oa; + lustre_set_wire_obdo(&body->oa, oa); ptlrpc_request_set_replen(req); @@ -466,7 +466,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, if (body == NULL) GOTO(out_req, rc = -EPROTO); - *oa = body->oa; + lustre_get_wire_obdo(oa, &body->oa); /* This should really be sent by the OST */ oa->o_blksize = PTLRPC_MAX_BRW_SIZE; @@ -514,7 +514,7 @@ static int osc_punch_interpret(const struct lu_env *env, if (body == NULL) GOTO(out, rc = -EPROTO); - *aa->pa_oa = body->oa; + lustre_get_wire_obdo(aa->pa_oa, &body->oa); out: rc = aa->pa_upcall(aa->pa_cookie, rc); RETURN(rc); @@ -546,7 +546,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa, body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - body->oa = *oa; + lustre_set_wire_obdo(&body->oa, oa); osc_pack_capa(req, body, capa); ptlrpc_request_set_replen(req); @@ -605,7 +605,7 @@ static int osc_sync(struct obd_export *exp, struct obdo *oa, /* overload the size and blocks fields in the oa with start/end */ body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - body->oa = *oa; + lustre_set_wire_obdo(&body->oa, oa); body->oa.o_size = start; body->oa.o_blocks = end; body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); @@ -621,7 +621,7 @@ static int osc_sync(struct obd_export *exp, struct obdo *oa, if (body == NULL) GOTO(out, rc = -EPROTO); - *oa = body->oa; + lustre_get_wire_obdo(oa, &body->oa); EXIT; out: @@ -734,7 +734,7 @@ static int osc_destroy(struct obd_export *exp, struct obdo *oa, oa->o_lcookie = *oti->oti_logcookies; body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); LASSERT(body); - body->oa = *oa; + lustre_set_wire_obdo(&body->oa, oa); osc_pack_capa(req, body, (struct obd_capa *)capa); ptlrpc_request_set_replen(req); @@ -1285,7 +1285,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, niobuf = req_capsule_client_get(pill, &RMF_NIOBUF_REMOTE); LASSERT(body && ioobj && niobuf); - body->oa = *oa; + lustre_set_wire_obdo(&body->oa, oa); obdo_to_ioobj(oa, ioobj); ioobj->ioo_bufcnt = niocount; @@ -1348,8 +1348,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, * it can be changed via lprocfs */ cksum_type_t cksum_type = cli->cl_cksum_type; - if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) - oa->o_flags = body->oa.o_flags = 0; + if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) { + oa->o_flags &= OBD_FL_LOCAL_MASK; + body->oa.o_flags = 0; + } body->oa.o_flags |= cksum_type_pack(cksum_type); body->oa.o_valid |= OBD_MD_FLCKSUM | OBD_MD_FLFLAGS; body->oa.o_cksum = osc_checksum_bulk(requested_nob, @@ -1606,7 +1608,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } out: if (rc >= 0) - *aa->aa_oa = body->oa; + lustre_get_wire_obdo(aa->aa_oa, &body->oa); RETURN(rc); } @@ -2185,6 +2187,9 @@ static int brw_interpret(const struct lu_env *env, int i; for (i = 0; i < aa->aa_page_count; i++) osc_release_write_grant(aa->aa_cli, aa->aa_ppga[i], 1); + + if (aa->aa_oa->o_flags & OBD_FL_TEMPORARY) + OBDO_FREE(aa->aa_oa); } osc_wake_cache_waiters(cli); osc_check_rpcs(env, cli);