From: Bruno Faccini Date: Sun, 7 Apr 2013 17:39:07 +0000 (+0200) Subject: LU-2991 osd: Overflow of transaction credits counters X-Git-Tag: 2.3.64~26 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=4c0564ce3e31dd6ef3d6f408210a6c8c464cb6a4 LU-2991 osd: Overflow of transaction credits counters Switching size of transaction credits counters from uchar to ushort to avoid possible overflow scenarios, like when wide-striping. Also allow OSD_TRACK_DECLARES to be undefined without compile-time errors for unsatisfied-externals/unused vars. Signed-off-by: Bruno Faccini Change-Id: I2588cf11741ca4e3ee80b795a7d4318f9ed4fd3d Reviewed-on: http://review.whamcloud.com/5830 Tested-by: Hudson Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 9ad62ed..135acf9 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -680,10 +680,15 @@ static struct thandle *osd_trans_create(const struct lu_env *env, CFS_INIT_LIST_HEAD(&oh->ot_dcb_list); osd_th_alloced(oh); - memset(oti->oti_declare_ops, 0, OSD_OT_MAX); - memset(oti->oti_declare_ops_rb, 0, OSD_OT_MAX); - memset(oti->oti_declare_ops_cred, 0, OSD_OT_MAX); +#ifdef OSD_TRACK_DECLARES + memset(oti->oti_declare_ops, 0, + sizeof(oti->oti_declare_ops)); + memset(oti->oti_declare_ops_rb, 0, + sizeof(oti->oti_declare_ops_rb)); + memset(oti->oti_declare_ops_cred, 0, + sizeof(oti->oti_declare_ops_cred)); oti->oti_rollback = false; +#endif } RETURN(th); } @@ -713,8 +718,10 @@ int osd_trans_start(const struct lu_env *env, struct dt_device *d, GOTO(out, rc); if (unlikely(osd_param_is_not_sane(dev, th))) { +#ifdef OSD_TRACK_DECLARES static unsigned long last_printed; static int last_credits; +#endif CWARN("%.16s: too many transaction credits (%d > %d)\n", LDISKFS_SB(osd_sb(dev))->s_es->s_volume_name, diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index b2c13b2..73432fe 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -595,8 +595,8 @@ struct osd_thread_info { /* Tracking for transaction credits, to allow debugging and optimizing * cases where a large number of credits are being allocated for * single transaction. */ - unsigned char oti_declare_ops[OSD_OT_MAX]; - unsigned char oti_declare_ops_rb[OSD_OT_MAX]; + unsigned short oti_declare_ops[OSD_OT_MAX]; + unsigned short oti_declare_ops_rb[OSD_OT_MAX]; unsigned short oti_declare_ops_cred[OSD_OT_MAX]; bool oti_rollback; #endif