Whamcloud - gitweb
b=18801
authoranserper <anserper>
Thu, 30 Jul 2009 16:59:18 +0000 (16:59 +0000)
committeranserper <anserper>
Thu, 30 Jul 2009 16:59:18 +0000 (16:59 +0000)
o=Christopher Morrone
i=Andrew Perepechko
i=Johann Lombardi

introduce a Lustre option to switch I/O to direct I/O (LLNL needs this)

lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c

index fb39d87..ce7cee3 100644 (file)
@@ -481,6 +481,11 @@ again:
                 it = &oit;
         }
 
+        if (ll_i2sbi(inode)->ll_direct_io_default &&
+            !S_ISDIR(inode->i_mode) &&
+            !(it->it_flags & FMODE_EXEC))
+                file->f_flags |= O_DIRECT;
+
 restart:
         /* Let's see if we have file open on MDS already. */
         if (it->it_flags & FMODE_WRITE) {
index 0a6fc23..f70df3b 100644 (file)
@@ -307,6 +307,8 @@ enum stats_track_type {
 #define SBI_DEFAULT_CONTENTION_SECONDS     60
 /* default value for lockless_truncate_enable */
 #define SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE 1
+/* default value for ll_direct_io_default */
+#define SBI_DEFAULT_DIRECT_IO_DEFAULT 0
 
 /* percpu data structure for lustre lru page list */
 struct ll_pglist_data {
@@ -366,6 +368,7 @@ struct ll_sb_info {
 
         unsigned                  ll_contention_time; /* seconds */
         unsigned                  ll_lockless_truncate_enable; /* true/false */
+        unsigned                  ll_direct_io_default; /* true/false */
 
         struct ll_ra_info         ll_ra_info;
         unsigned int              ll_namelen;
index d016bab..04a0d13 100644 (file)
@@ -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_direct_io_default = SBI_DEFAULT_DIRECT_IO_DEFAULT;
         INIT_LIST_HEAD(&sbi->ll_conn_chain);
         INIT_LIST_HEAD(&sbi->ll_orphan_dentry_list);
 
index 579010b..149f463 100644 (file)
@@ -576,6 +576,27 @@ static int ll_wr_lockless_truncate(struct file *file, const char *buffer,
                 ?: count;
 }
 
+static int ll_rd_direct_io_default(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_direct_io_default);
+}
+
+static int ll_wr_direct_io_default(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_direct_io_default)
+                ?: count;
+}
+
 static int ll_rd_statahead_max(char *page, char **start, off_t off,
                                int count, int *eof, void *data)
 {
@@ -683,6 +704,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},
+        { "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 },
         { "statahead_stats",    ll_rd_statahead_stats, 0, 0 },
         { "lazystatfs",         ll_rd_lazystatfs, ll_wr_lazystatfs, 0 },