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);
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;
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;
EXPORT_SYMBOL(lprocfs_rd_filegroups);
EXPORT_SYMBOL(lprocfs_write_helper);
+EXPORT_SYMBOL(lprocfs_write_u64_helper);
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);
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,
{
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)
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 },
//{ "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 }
};