From: Andrew Perepechko Date: Fri, 26 Nov 2010 01:29:34 +0000 (+0300) Subject: b=24201 add procfs tunable to enable/disable lockless direct I/O X-Git-Tag: 1.8.5.51~32 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7026aa46c2a9c6c3ebd61d585538dd83de00de0a;p=fs%2Flustre-release.git b=24201 add procfs tunable to enable/disable lockless direct I/O llite.lustre-*.lockless_direct_io=0 will disable default semantics of direct I/O that forces it to be lockless. lockless_direct_io value, however, will be ignored if per-file LL_FILE_LOCKED_DIRECTIO bit is set. i=Johann Lombardi --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 882bfaa..6acf7f5 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1143,9 +1143,16 @@ static int ll_is_file_contended(struct file *file) if (fd && (fd->fd_flags & LL_FILE_IGNORE_LOCK)) RETURN(0); - /* server-side locking for dio unless LL_FILE_LOCKED_DIRECTIO */ + /* The semantics here is a bit complicated due to compatibility. + * The user may be aware of per-file LL_FILE_LOCKED_DIRECTIO, + * but not of per-client lockless_direct_io, so the file bit takes + * precedence if it is set. If the file bit is not set, we use + * lockless I/O unless per-client lockless_direct_io is set to zero. + */ + CLASSERT(SBI_DEFAULT_LOCKLESS_DIRECT_IO == 1); if ((file->f_flags & O_DIRECT) && - !(fd && (fd->fd_flags & LL_FILE_LOCKED_DIRECTIO))) + !(fd && (fd->fd_flags & LL_FILE_LOCKED_DIRECTIO)) && + sbi->ll_lockless_direct_io) RETURN(1); /* server-side locking for cached I/O with LL_FILE_LOCKLESS_IO */ diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 70ab767..b35f799 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -311,6 +311,7 @@ enum stats_track_type { #define SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE 0 /* see bug 23175 */ /* default value for ll_direct_io_default */ #define SBI_DEFAULT_DIRECT_IO_DEFAULT 0 +#define SBI_DEFAULT_LOCKLESS_DIRECT_IO 1 /* percpu data structure for lustre lru page list */ struct ll_pglist_data { @@ -370,6 +371,7 @@ struct ll_sb_info { unsigned ll_contention_time; /* seconds */ unsigned ll_lockless_truncate_enable; /* true/false */ + unsigned ll_lockless_direct_io; /* true/false */ unsigned ll_direct_io_default; /* true/false */ struct ll_ra_info ll_ra_info; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index a0bd6ad..4c60593 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -176,6 +176,7 @@ static struct ll_sb_info *ll_init_sbi(void) SBI_DEFAULT_READAHEAD_WHOLE_MAX; sbi->ll_contention_time = SBI_DEFAULT_CONTENTION_SECONDS; sbi->ll_lockless_truncate_enable = SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE; + sbi->ll_lockless_direct_io = SBI_DEFAULT_LOCKLESS_DIRECT_IO; sbi->ll_direct_io_default = SBI_DEFAULT_DIRECT_IO_DEFAULT; INIT_LIST_HEAD(&sbi->ll_conn_chain); INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list); diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 15b514a..c6f280b 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -597,6 +597,27 @@ static int ll_wr_direct_io_default(struct file *file, const char *buffer, ?: count; } +static int ll_rd_lockless_direct_io(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct super_block *sb = data; + + *eof = 1; + return snprintf(page, count, "%u\n", + ll_s2sbi(sb)->ll_lockless_direct_io); +} + +static int ll_wr_lockless_direct_io(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct super_block *sb = data; + struct ll_sb_info *sbi = ll_s2sbi(sb); + + return lprocfs_write_helper(buffer, count, + &sbi->ll_lockless_direct_io) + ?: count; +} + static int ll_rd_statahead_max(char *page, char **start, off_t off, int count, int *eof, void *data) { @@ -704,6 +725,8 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { ll_wr_contention_time, 0}, { "lockless_truncate", ll_rd_lockless_truncate, ll_wr_lockless_truncate, 0}, + { "lockless_direct_io", ll_rd_lockless_direct_io, + ll_wr_lockless_direct_io, 0}, { "direct_io_default", ll_rd_direct_io_default, ll_wr_direct_io_default, 0}, { "statahead_max", ll_rd_statahead_max, ll_wr_statahead_max, 0 },