From a7397d4bee2547104bda3cf5492fff8488bdc2df Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Wed, 5 May 2010 10:47:19 +0800 Subject: [PATCH] b=22241 move sync on block cancel tunable to filter move the tunable of journal sync on lock block cancel to filter from ost i=oleg.drokin@sun.com i=hongchao.zhang@sun.com --- lustre/include/obd.h | 11 ++++++++- lustre/obdfilter/filter.c | 7 ++++++ lustre/obdfilter/filter_internal.h | 11 ++++++++- lustre/obdfilter/lproc_obdfilter.c | 47 ++++++++++++++++++++++++++++++++++++++ lustre/ost/lproc_ost.c | 46 ------------------------------------- lustre/ost/ost_handler.c | 19 ++++++++------- lustre/ost/ost_internal.h | 8 ------- 7 files changed, 85 insertions(+), 64 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index b328292..638d7c9 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -349,6 +349,7 @@ struct filter_obd { unsigned long fo_read_cache:1, /* read-only cache */ fo_writethrough_cache:1, /* writetrhough cache */ fo_syncjournal:1, /* sync journal on writes */ + fo_sync_lock_cancel:2, /* sync on lock cancel */ fo_raid_degraded:1; /* RAID device degraded */ struct obd_import *fo_mdc_imp; @@ -401,6 +402,14 @@ struct filter_obd { #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */ #define OSC_DEFAULT_RESENDS 10 +/* possible values for fo_sync_lock_cancel */ +enum { + NEVER_SYNC_ON_CANCEL = 0, + BLOCKING_SYNC_ON_CANCEL = 1, + ALWAYS_SYNC_ON_CANCEL = 2, + NUM_SYNC_ON_CANCEL_STATES +}; + #define MDC_MAX_RIF_DEFAULT 8 #define MDC_MAX_RIF_MAX 512 @@ -657,7 +666,6 @@ struct ost_obd { struct ptlrpc_service *ost_create_service; struct ptlrpc_service *ost_io_service; struct semaphore ost_health_sem; - int ost_sync_on_lock_cancel; }; struct echo_client_obd { @@ -1108,6 +1116,7 @@ enum obd_cleanup_stage { #define KEY_MAX_EASIZE "max_ea_size" #define KEY_FIEMAP "fiemap" #define KEY_CONNECT_FLAG "connect_flags" +#define KEY_SYNC_LOCK_CANCEL "sync_lock_cancel" /* XXX unused */ #define KEY_ASYNC "async" #define KEY_CAPA_KEY "capa_key" diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 0990f53..278793a 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1958,6 +1958,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf, filter->fo_fmd_max_num = FILTER_FMD_MAX_NUM_DEFAULT; filter->fo_fmd_max_age = FILTER_FMD_MAX_AGE_DEFAULT; filter->fo_syncjournal = 1; /* Sync journals on i/o by default b=19128 */ + filter_slc_set(filter); /* initialize sync on lock cancel */ rc = filter_prep(obd); if (rc) @@ -3895,6 +3896,12 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen, RETURN(rc); } + if (KEY_IS(KEY_SYNC_LOCK_CANCEL)) { + *((__u32 *) val) = obd->u.filter.fo_sync_lock_cancel; + *vallen = sizeof(__u32); + RETURN(0); + } + CDEBUG(D_IOCTL, "invalid key\n"); RETURN(-EINVAL); } diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 23fe364..1d46108 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -225,5 +225,14 @@ static void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars) /* Quota stuff */ extern quota_interface_t *filter_quota_interface_ref; - +/* sync on lock cancel is useless when we force a journal flush, + * and if we enable async journal commit, we should also turn on + * sync on lock cancel if it is not enabled already. */ +static inline void filter_slc_set(struct filter_obd *filter) +{ + if (filter->fo_syncjournal == 1) + filter->fo_sync_lock_cancel = NEVER_SYNC_ON_CANCEL; + else if (filter->fo_sync_lock_cancel == NEVER_SYNC_ON_CANCEL) + filter->fo_sync_lock_cancel = ALWAYS_SYNC_ON_CANCEL; +} #endif /* _FILTER_INTERNAL_H */ diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c index 35ee378..a179928 100644 --- a/lustre/obdfilter/lproc_obdfilter.c +++ b/lustre/obdfilter/lproc_obdfilter.c @@ -262,6 +262,51 @@ int lprocfs_filter_wr_syncjournal(struct file *file, const char *buffer, return -EINVAL; obd->u.filter.fo_syncjournal = !!val; + filter_slc_set(&obd->u.filter); + + return count; +} + +static char *sync_on_cancel_states[] = {"never", + "blocking", + "always" }; + +int lprocfs_filter_rd_sync_lock_cancel(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct obd_device *obd = data; + int rc; + + rc = snprintf(page, count, "%s\n", + sync_on_cancel_states[obd->u.filter.fo_sync_lock_cancel]); + return rc; +} + +int lprocfs_filter_wr_sync_lock_cancel(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct obd_device *obd = data; + int val = -1; + int i; + + for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) { + if (memcmp(buffer, sync_on_cancel_states[i], + strlen(sync_on_cancel_states[i])) == 0) { + val = i; + break; + } + } + if (val == -1) { + int rc; + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) + return rc; + } + + if (val < 0 || val > 2) + return -EINVAL; + + obd->u.filter.fo_sync_lock_cancel = val; return count; } @@ -344,6 +389,8 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = { #endif { "sync_journal", lprocfs_filter_rd_syncjournal, lprocfs_filter_wr_syncjournal, 0 }, + { "sync_on_lock_cancel", lprocfs_filter_rd_sync_lock_cancel, + lprocfs_filter_wr_sync_lock_cancel, 0 }, { "degraded", lprocfs_filter_rd_degraded, lprocfs_filter_wr_degraded, 0 }, { 0 } diff --git a/lustre/ost/lproc_ost.c b/lustre/ost/lproc_ost.c index 9bb91ba..9cb8912 100644 --- a/lustre/ost/lproc_ost.c +++ b/lustre/ost/lproc_ost.c @@ -41,54 +41,8 @@ #include "ost_internal.h" #ifdef LPROCFS -static char *sync_on_cancel_states[] = {"never", - "blocking", - "always" }; - -int lprocfs_ost_rd_ost_sync_on_lock_cancel(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - struct obd_device *obd = data; - int rc; - - rc = snprintf(page, count, "%s\n", - sync_on_cancel_states[obd->u.ost.ost_sync_on_lock_cancel]); - return rc; -} - -int lprocfs_ost_wr_ost_sync_on_lock_cancel(struct file *file, - const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = data; - int val = -1; - int i; - - for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) { - if (memcmp(buffer, sync_on_cancel_states[i], - strlen(sync_on_cancel_states[i])) == 0) { - val = i; - break; - } - } - if (val == -1) { - int rc; - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - } - - if (val < 0 || val > 2) - return -EINVAL; - - obd->u.ost.ost_sync_on_lock_cancel = val; - return count; -} - static struct lprocfs_vars lprocfs_ost_obd_vars[] = { { "uuid", lprocfs_rd_uuid, 0, 0 }, - { "sync_on_lock_cancel", lprocfs_ost_rd_ost_sync_on_lock_cancel, - lprocfs_ost_wr_ost_sync_on_lock_cancel, 0 }, { 0 } }; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index f36efc3..cc6d3fd 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1384,14 +1384,20 @@ int ost_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - struct obd_device *obd = lock->l_export->exp_obd; - if (flag == LDLM_CB_CANCELING && + __u32 sync_lock_cancel = 0; + __u32 len = sizeof(sync_lock_cancel); + int rc = 0; + ENTRY; + + rc = obd_get_info(lock->l_export, sizeof(KEY_SYNC_LOCK_CANCEL), + KEY_SYNC_LOCK_CANCEL, &len, &sync_lock_cancel, NULL); + + if (!rc && flag == LDLM_CB_CANCELING && (lock->l_granted_mode & (LCK_PW|LCK_GROUP)) && - (obd->u.ost.ost_sync_on_lock_cancel == ALWAYS_SYNC_ON_CANCEL || - (obd->u.ost.ost_sync_on_lock_cancel == BLOCKING_SYNC_ON_CANCEL && + (sync_lock_cancel == ALWAYS_SYNC_ON_CANCEL || + (sync_lock_cancel == BLOCKING_SYNC_ON_CANCEL && lock->l_flags & LDLM_FL_CBPENDING))) { struct obd_info *oinfo; - int rc; OBD_ALLOC_PTR(oinfo); if (!oinfo) @@ -2045,9 +2051,6 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf) sema_init(&ost->ost_health_sem, 1); - /* Always sync on lock cancel */ - ost->ost_sync_on_lock_cancel = ALWAYS_SYNC_ON_CANCEL; - if (oss_num_threads) { /* If oss_num_threads is set, it is the min and the max. */ if (oss_num_threads > OSS_THREADS_MAX) diff --git a/lustre/ost/ost_internal.h b/lustre/ost/ost_internal.h index 8203885..dad6209 100644 --- a/lustre/ost/ost_internal.h +++ b/lustre/ost/ost_internal.h @@ -76,12 +76,4 @@ static void lprocfs_ost_init_vars(struct lprocfs_static_vars *lvars) memset(lvars, 0, sizeof(*lvars)); } #endif - -enum { - NEVER_SYNC_ON_CANCEL = 0, - BLOCKING_SYNC_ON_CANCEL = 1, - ALWAYS_SYNC_ON_CANCEL = 2, - NUM_SYNC_ON_CANCEL_STATES -}; - #endif /* OST_INTERNAL_H */ -- 1.8.3.1