Whamcloud - gitweb
Allow OST read cache to be disabled (already on b1_0).
authoradilger <adilger>
Wed, 28 Jan 2004 22:47:19 +0000 (22:47 +0000)
committeradilger <adilger>
Wed, 28 Jan 2004 22:47:19 +0000 (22:47 +0000)
b=2591
r=zab,shaver

lustre/include/linux/lprocfs_status.h
lustre/include/linux/obd.h
lustre/obdclass/lprocfs_status.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/obdfilter/lproc_obdfilter.c

index 8fbbe61..3f4d52f 100644 (file)
@@ -256,9 +256,11 @@ extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
                                  int count, int *eof, void *data);
 
-extern int lprocfs_write_helper(const char *buffer, unsigned long count, 
+extern int lprocfs_write_helper(const char *buffer, unsigned long count,
                                 int *val);
-int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode, 
+extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+                                    __u64 *val);
+int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode,
                            struct file_operations *seq_fops, void *data);
 struct obd_histogram;
 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
index 3982a4c..d946942 100644 (file)
@@ -168,6 +168,8 @@ struct filter_obd {
         obd_size             fo_tot_granted;
         obd_size             fo_tot_cached;
 
+        obd_size             fo_readcache_max_filesize;
+
         struct obd_import   *fo_mdc_imp;
         struct obd_uuid      fo_mdc_uuid;
         struct lustre_handle fo_mdc_conn;
index a5ad77c..eb98251 100644 (file)
@@ -684,7 +684,27 @@ int lprocfs_write_helper(const char *buffer, unsigned long count,
         return 0;
 }
 
-int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode, 
+int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+                             __u64 *val)
+{
+        char kernbuf[22], *end;
+
+        if (count > (sizeof(kernbuf) - 1))
+                return -EINVAL;
+
+        if (copy_from_user(kernbuf, buffer, count))
+                return -EFAULT;
+
+        kernbuf[count] = '\0';
+
+        *val = simple_strtoull(kernbuf, &end, 0);
+        if (kernbuf == end)
+                return -EINVAL;
+
+        return 0;
+}
+
+int lprocfs_obd_seq_create(struct obd_device *dev, char *name, mode_t mode,
                            struct file_operations *seq_fops, void *data)
 {
         struct proc_dir_entry *entry;
@@ -774,3 +794,4 @@ EXPORT_SYMBOL(lprocfs_rd_filesfree);
 EXPORT_SYMBOL(lprocfs_rd_filegroups);
 
 EXPORT_SYMBOL(lprocfs_write_helper);
+EXPORT_SYMBOL(lprocfs_write_u64_helper);
index 86eda2d..93d363e 100644 (file)
@@ -1123,6 +1123,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         spin_lock_init(&filter->fo_w_discont_pages.oh_lock);
         spin_lock_init(&filter->fo_r_discont_blocks.oh_lock);
         spin_lock_init(&filter->fo_w_discont_blocks.oh_lock);
+        filter->fo_readcache_max_filesize = FILTER_MAX_CACHE_SIZE;
 
         obd->obd_namespace = ldlm_namespace_new("filter-tgt",
                                                 LDLM_NAMESPACE_SERVER);
index 610d969..ce7b4a3 100644 (file)
@@ -90,6 +90,8 @@ enum {
         LPROC_FILTER_LAST,
 };
 
+#define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF
+
 /* filter.c */
 struct dentry *filter_parent(struct obd_device *, obd_gr group, obd_id objid);
 struct dentry *filter_parent_lock(struct obd_device *, obd_gr, obd_id,
index 774e669..afb49db 100644 (file)
@@ -360,13 +360,24 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
 {
         struct obd_ioobj *o;
         struct niobuf_local *lnb;
-        int i, j;
+        int i, j, drop = 0;
         ENTRY;
 
+        if (res->dentry != NULL)
+                drop = (res->dentry->d_inode->i_size >
+                        exp->exp_obd->u.filter.fo_readcache_max_filesize);
+
         for (i = 0, o = obj, lnb = res; i < objcount; i++, o++) {
                 for (j = 0 ; j < o->ioo_bufcnt ; j++, lnb++) {
-                        if (lnb->page != NULL)
-                                page_cache_release(lnb->page);
+                        if (lnb->page == NULL)
+                                continue;
+                        /* drop from cache like truncate_list_pages() */
+                        if (drop && !TryLockPage(lnb->page)) {
+                                if (lnb->page->mapping)
+                                        truncate_complete_page(lnb->page);
+                                unlock_page(lnb->page);
+                        }
+                        page_cache_release(lnb->page);
                 }
         }
         if (res->dentry != NULL)
index 77f0852..51458c0 100644 (file)
@@ -58,6 +58,32 @@ static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off,
                         filter_last_id(&obd->u.filter, 0));
 }
 
+int lprocfs_filter_rd_readcache(char *page, char **start, off_t off, int count,
+                                int *eof, void *data)
+{
+        struct obd_device *obd = data;
+        int rc;
+
+        rc = snprintf(page, count, LPU64"\n",
+                      obd->u.filter.fo_readcache_max_filesize);
+        return rc;
+}
+
+int lprocfs_filter_wr_readcache(struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        __u64 val;
+        int rc;
+
+        rc = lprocfs_write_u64_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.filter.fo_readcache_max_filesize = val;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",         lprocfs_rd_uuid,          0, 0 },
         { "blocksize",    lprocfs_rd_blksize,       0, 0 },
@@ -68,7 +94,10 @@ static struct lprocfs_vars lprocfs_obd_vars[] = {
         //{ "filegroups",   lprocfs_rd_filegroups,    0, 0 },
         { "fstype",       lprocfs_rd_fstype,        0, 0 },
         { "mntdev",       lprocfs_filter_rd_mntdev, 0, 0 },
-        { "last_id",      lprocfs_filter_rd_last_id, 0, 0 },
+        { "last_id",      lprocfs_filter_rd_last_id,0, 0 },
+        { "readcache_max_filesize",
+                          lprocfs_filter_rd_readcache,
+                          lprocfs_filter_wr_readcache, 0 },
         { 0 }
 };