]> git.karo-electronics.de Git - linux-beck.git/commitdiff
orangefs: do not allow client readahead cache without feature bit
authorMartin Brandenburg <martin@omnibond.com>
Fri, 12 Aug 2016 20:12:09 +0000 (16:12 -0400)
committerMartin Brandenburg <martin@omnibond.com>
Fri, 12 Aug 2016 20:12:09 +0000 (16:12 -0400)
Signed-off-by: Martin Brandenburg <martin@omnibond.com>
fs/orangefs/file.c
fs/orangefs/orangefs-sysfs.c

index 43c08b5c71686fc6f49b91af53076fe152dc6455..fe5e1eac95619b821c4ec50ebc41b93a8617413f 100644 (file)
@@ -624,11 +624,14 @@ static int orangefs_file_release(struct inode *inode, struct file *file)
        if (file->f_path.dentry->d_inode &&
            file->f_path.dentry->d_inode->i_mapping &&
            mapping_nrpages(&file->f_path.dentry->d_inode->i_data)) {
-               gossip_debug(GOSSIP_INODE_DEBUG,
-                   "calling flush_racache on %pU\n",
-                   get_khandle_from_ino(inode));
-               flush_racache(inode);
-               gossip_debug(GOSSIP_INODE_DEBUG, "flush_racache finished\n");
+               if (orangefs_features & ORANGEFS_FEATURE_READAHEAD) {
+                       gossip_debug(GOSSIP_INODE_DEBUG,
+                           "calling flush_racache on %pU\n",
+                           get_khandle_from_ino(inode));
+                       flush_racache(inode);
+                       gossip_debug(GOSSIP_INODE_DEBUG,
+                           "flush_racache finished\n");
+               }
                truncate_inode_pages(file->f_path.dentry->d_inode->i_mapping,
                                     0);
        }
index 2fe9a3a2117bd450103a623b4fa53889cca64d88..ed5ee33d0f7ea3fc6521c1ed638ae11196df58d7 100644 (file)
@@ -842,6 +842,16 @@ static int sysfs_service_op_show(char *kobj_id, char *buf, void *attr)
        if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
                orangefs_attr = (struct orangefs_attribute *)attr;
 
+               /* Drop unsupported requests first. */
+               if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
+                   (!strcmp(orangefs_attr->attr.name, "readahead_count") ||
+                   !strcmp(orangefs_attr->attr.name, "readahead_size") ||
+                   !strcmp(orangefs_attr->attr.name,
+                   "readahead_count_size"))) {
+                       rc = -EINVAL;
+                       goto out;
+               }
+
                if (!strcmp(orangefs_attr->attr.name, "perf_history_size"))
                        new_op->upcall.req.param.op =
                                ORANGEFS_PARAM_REQUEST_OP_PERF_HISTORY_SIZE;
@@ -1133,6 +1143,15 @@ static int sysfs_service_op_store(char *kobj_id, const char *buf, void *attr)
 
        if (!strcmp(kobj_id, ORANGEFS_KOBJ_ID)) {
                orangefs_attr = (struct orangefs_attribute *)attr;
+               /* Drop unsupported requests first. */
+               if (!(orangefs_features & ORANGEFS_FEATURE_READAHEAD) &&
+                   (!strcmp(orangefs_attr->attr.name, "readahead_count") ||
+                   !strcmp(orangefs_attr->attr.name, "readahead_size") ||
+                   !strcmp(orangefs_attr->attr.name,
+                   "readahead_count_size"))) {
+                       rc = -EINVAL;
+                       goto out;
+               }
 
                if (!strcmp(orangefs_attr->attr.name, "perf_history_size")) {
                        if (val > 0) {