Orangefs Through the Pagecache
Subsystems (2)
cover Orangefs Through the Pagecache
From: Mike Marshall <[email protected]>
Until now the Orangefs kernel module has not gone through the pagecache and has been a de facto O_DIRECT style module.
This patch series adds pagecache support and greatly improves small IO. For example, xfstest generic/069 used to take several hours on our test VMs, and now finishes in seconds.
Orangefs' kernel module shares a memory buffer with Orangefs' userspace parts for IO. Orangefs can best exploit parallelism when the buffer is significantly filled, and struggles when the buffer is nearly empty. Buffering reads and writes through the pagecache helps us to communicate with userspace less often with buffers that are more full.
Reads can be tuned with "count" from read(2) to simulate page sizes more in line with Orangefs's buffer size (4 meg by default). Userspace will deposit "count" bytes in the shared buffer on a read and when the VFS calls orangefs_readpage, as many pagecache pages as possible will be filled at once.
Writes are coalesced even across pages when possible up to the size of the buffer between the OrangeFS client core and the kernel. This is 4 MB by default. This means that an application writing with a block size less than 4 MB will have its writes upgraded. For sequential writes, this is a big improvement.
Martin Brandenburg (19):
orangefs: implement xattr cache
orangefs: do not invalidate attributes on inode create
orangefs: simplify orangefs_inode_getattr interface
orangefs: update attributes rather than relying on server
orangefs: hold i_lock during inode_getattr
orangefs: set up and use backing_dev_info
orangefs: let setattr write to cached inode
orangefs: reorganize setattr functions to track attribute changes
orangefs: remove orangefs_readpages
orangefs: service ops done for writeback are not killable
orangefs: migrate to generic_file_read_iter
orangefs: implement writepage
orangefs: do not return successful read when the client-core
disappeared
orangefs: move do_readv_writev to direct_IO
orangefs: skip inode writeout if nothing to write
orangefs: avoid fsync service operation on flush
orangefs: write range tracking
orangefs: implement writepages
orangefs: add orangefs_revalidate_mapping
Mike Marshall (3):
orangefs: remember count when reading.
orangefs: pass slot index back to readpage.
orangefs: copy Orangefs-sized blocks into the pagecache if possible.
fs/orangefs/acl.c | 4 +- fs/orangefs/file.c | 389 ++++++-------- fs/orangefs/inode.c | 908 +++++++++++++++++++++++++++++---- fs/orangefs/namei.c | 40 +- fs/orangefs/orangefs-bufmap.c | 13 + fs/orangefs/orangefs-bufmap.h | 2 + fs/orangefs/orangefs-debugfs.c | 4 +- fs/orangefs/orangefs-kernel.h | 56 +- fs/orangefs/orangefs-mod.c | 1 + fs/orangefs/orangefs-sysfs.c | 22 + fs/orangefs/orangefs-utils.c | 179 +++---- fs/orangefs/super.c | 39 +- fs/orangefs/waitqueue.c | 18 +- fs/orangefs/xattr.c | 106 +++- 14 files changed, 1293 insertions(+), 488 deletions(-)
Signature · 1 line
2.20.1
PATCH 2/22 orangefs: do not invalidate attributes on inode create
From: Martin Brandenburg <[email protected]>
When an inode is created, we fetch attributes from the server. There is no need to turn around and invalidate them.
No need to initialize attributes after the getattr either. Either it'll be exactly the same, or it'll be something else and wrong.
--- fs/orangefs/inode.c | 6 ------ fs/orangefs/namei.c | 6 ------ 2 files changed, 12 deletions(-)
fs/orangefs/inode.c +0 -6
@@ -460,12 +460,6 @@ struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, goto out_iput;orangefs_init_iops (inode); - - inode->i_mode = mode; - inode->i_uid =current_fsuid (); - inode->i_gid =current_fsgid (); - inode->i_atime = inode->i_mtime = inode->i_ctime =current_time (inode); - inode->i_size =PAGE_SIZE ; inode->i_rdev = dev; error =insert_inode_locked4 (inode, hash, orangefs_test_inode, ref);
fs/orangefs/namei.c +0 -6
@@ -76,8 +76,6 @@ static int orangefs_create(struct inode *dir,d_instantiate_new (dentry, inode);orangefs_set_timeout (dentry); -ORANGEFS_I (inode)->getattr_time = jiffies -1 ; -ORANGEFS_I (inode)->getattr_mask =STATX_BASIC_STATS ; gossip_debug(GOSSIP_NAME_DEBUG, "%s: dentry instantiated for %pd\n",
@@ -291,8 +289,6 @@ static int orangefs_symlink(struct inode *dir,d_instantiate_new (dentry, inode);orangefs_set_timeout (dentry); -ORANGEFS_I (inode)->getattr_time = jiffies -1 ; -ORANGEFS_I (inode)->getattr_mask =STATX_BASIC_STATS ; gossip_debug(GOSSIP_NAME_DEBUG, "Inode (Symlink) %pU -> %pd\n",
@@ -360,8 +356,6 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t moded_instantiate_new (dentry, inode);orangefs_set_timeout (dentry); -ORANGEFS_I (inode)->getattr_time = jiffies -1 ; -ORANGEFS_I (inode)->getattr_mask =STATX_BASIC_STATS ; gossip_debug(GOSSIP_NAME_DEBUG, "Inode (Directory) %pU -> %pd\n",
Signature · 1 line
2.20.1
PATCH 1/22 orangefs: implement xattr cache
In reply to [email protected]From: Martin Brandenburg <[email protected]>
This uses the same timeout as the getattr cache. This substantially increases performance when writing files with smaller buffer sizes.
When writing, the size is (often) changed, which causes a call to notify_change which calls security_inode_need_killpriv which needs a getxattr. Caching it reduces traffic to the server.
--- fs/orangefs/inode.c | 1 + fs/orangefs/orangefs-kernel.h | 11 ++++ fs/orangefs/super.c | 10 ++++ fs/orangefs/xattr.c | 106 +++++++++++++++++++++++++++++++++- 4 files changed, 127 insertions(+), 1 deletion(-)
fs/orangefs/inode.c +1 -0
@@ -364,6 +364,7 @@ static int orangefs_set_inode(struct inode *inode, void *data)struct orangefs_object_kref *ref = (struct orangefs_object_kref *) data;ORANGEFS_I (inode)->refn.fs_id = ref->fs_id;ORANGEFS_I (inode)->refn.khandle = ref->khandle; +hash_init (ORANGEFS_I (inode)->xattr_cache);return 0 ; }
fs/orangefs/orangefs-kernel.h +11 -0
@@ -51,6 +51,7 @@#include <linux/rwsem.h> #include <linux/xattr.h> #include <linux/exportfs.h> +#include <linux/hashtable.h> #include <asm/unaligned.h>
@@ -193,6 +194,8 @@ struct orangefs_inode_s {unsigned long getattr_time;u32 getattr_mask; + +DECLARE_HASHTABLE (xattr_cache,4 ); };/* per superblock private orangefs info */
@@ -217,6 +220,14 @@ struct orangefs_stats {unsigned long writes; }; +struct orangefs_cached_xattr { +struct hlist_node node; +char key[ORANGEFS_MAX_XATTR_NAMELEN ]; +char val[ORANGEFS_MAX_XATTR_VALUELEN ]; +ssize_t length; +unsigned long timeout; +}; +extern struct orangefs_stats orangefs_stats;/*
fs/orangefs/super.c +10 -0
@@ -10,6 +10,7 @@#include "orangefs-bufmap.h" #include <linux/parser.h> +#include <linux/hashtable.h> /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */ static struct kmem_cache *orangefs_inode_cache;
@@ -128,6 +129,15 @@ static void orangefs_i_callback(struct rcu_head *head) { struct inode *inode = container_of(head, struct inode, i_rcu);struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode); +struct orangefs_cached_xattr *cx; +struct hlist_node *tmp; +int i; + +hash_for_each_safe (orangefs_inode->xattr_cache, i, tmp, cx, node) { +hlist_del (&cx->node); +kfree (cx); + } +kmem_cache_free (orangefs_inode_cache, orangefs_inode); }
fs/orangefs/xattr.c +105 -1
172 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/22 orangefs: simplify orangefs_inode_getattr interface
In reply to [email protected]From: Martin Brandenburg <[email protected]>
No need to store the received mask. It is either STATX_BASIC_STATS or STATX_BASIC_STATS & ~STATX_SIZE. If STATX_SIZE is requested, the cache is bypassed anyway, so the cached mask is unnecessary to decide whether to do a real getattr.
This is a change. Previously a getattr would want size and use the cached size. All of the in-kernel callers that wanted size did not want a cached size. Now a getattr cannot use the cached size if it wants size at all.
--- fs/orangefs/file.c | 17 ++++++++--------- fs/orangefs/inode.c | 11 ++++++----- fs/orangefs/orangefs-kernel.h | 7 ++++--- fs/orangefs/orangefs-utils.c | 31 ++++++++++--------------------- 4 files changed, 28 insertions(+), 38 deletions(-)
fs/orangefs/file.c +8 -9
@@ -420,8 +420,8 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite/* Make sure generic_write_checks sees an up to date inode size. */ if (file->f_flags &O_APPEND ) { - rc =orangefs_inode_getattr (file->f_mapping->host,0 ,1 , -STATX_SIZE ); + rc =orangefs_inode_getattr (file->f_mapping->host, +ORANGEFS_GETATTR_SIZE );if (rc == -ESTALE ) rc = -EIO ;if (rc) {
@@ -528,14 +528,13 @@ static vm_fault_t orangefs_fault(struct vm_fault *vmf) {struct file *file = vmf->vma->vm_file;int ret; - - ret =orangefs_inode_getattr (file->f_mapping->host,0 ,1 , -STATX_SIZE ); + ret =orangefs_inode_getattr (file->f_mapping->host, +ORANGEFS_GETATTR_SIZE );if (ret == -ESTALE ) ret = -EIO ;if (ret) { -gossip_err ("%s: orangefs_inode_getattr failed, ret:%d:.\n" , - __func__, ret); +gossip_err ("%s: orangefs_inode_getattr failed, " +"ret:%d:.\n" , __func__, ret);return VM_FAULT_SIGBUS ; }return filemap_fault (vmf);
@@ -656,8 +655,8 @@ static loff_t orangefs_file_llseek(struct file *file, loff_t offset, int origin)* NOTE: We are only interested in file size here, * so we set mask accordingly. */ - ret =orangefs_inode_getattr (file->f_mapping->host,0 ,1 , -STATX_SIZE ); + ret =orangefs_inode_getattr (file->f_mapping->host, +ORANGEFS_GETATTR_SIZE );if (ret == -ESTALE ) ret = -EIO ;if (ret) {
fs/orangefs/inode.c +6 -5
@@ -162,7 +162,7 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) iattr->ia_size);/* Ensure that we have a up to date size, so we know if it changed. */ - ret =orangefs_inode_getattr (inode,0 ,1 ,STATX_SIZE ); + ret =orangefs_inode_getattr (inode,ORANGEFS_GETATTR_SIZE );if (ret == -ESTALE ) ret = -EIO ;if (ret) {
@@ -256,7 +256,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,"orangefs_getattr: called on %pd\n" , path->dentry); - ret =orangefs_inode_getattr (inode,0 ,0 , request_mask); + ret =orangefs_inode_getattr (inode, + request_mask &STATX_SIZE ?ORANGEFS_GETATTR_SIZE :0 );if (ret ==0 ) {generic_fillattr (inode, stat);
@@ -284,7 +285,7 @@ int orangefs_permission(struct inode *inode, int mask)gossip_debug (GOSSIP_INODE_DEBUG ,"%s: refreshing\n" , __func__);/* Make sure the permission (and other common attrs) are up to date. */ - ret =orangefs_inode_getattr (inode,0 ,0 ,STATX_MODE ); + ret =orangefs_inode_getattr (inode,0 );if (ret <0 )return ret;
@@ -410,7 +411,7 @@ struct inode *orangefs_iget(struct super_block *sb,if (!(inode->i_state &I_NEW ))return inode; - error =orangefs_inode_getattr (inode,1 ,1 ,STATX_ALL ); + error =orangefs_inode_getattr (inode,ORANGEFS_GETATTR_NEW );if (error) {iget_failed (inode);return ERR_PTR (error);
@@ -455,7 +456,7 @@ struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir,orangefs_set_inode (inode, ref); inode->i_ino = hash;/* needed for stat etc */ - error =orangefs_inode_getattr (inode,1 ,1 ,STATX_ALL ); + error =orangefs_inode_getattr (inode,ORANGEFS_GETATTR_NEW );if (error) goto out_iput;
fs/orangefs/orangefs-kernel.h +4 -3
@@ -193,7 +193,6 @@ struct orangefs_inode_s {sector_t last_failed_block_index_read;unsigned long getattr_time; -u32 getattr_mask;DECLARE_HASHTABLE (xattr_cache,4 ); };
@@ -397,8 +396,10 @@ int orangefs_inode_setxattr(struct inode *inode,size_t size, int flags); -int orangefs_inode_getattr (struct inode *inode,int new,int bypass, -u32 request_mask); +#define ORANGEFS_GETATTR_NEW 1 +#define ORANGEFS_GETATTR_SIZE 2 + +int orangefs_inode_getattr (struct inode *,int );int orangefs_inode_check_changed (struct inode *inode);
fs/orangefs/orangefs-utils.c +10 -21
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 /* * (C) 2001 Clemson University and The University of Chicago +* Copyright 2018 Omnibond Systems, L.L.C. * * See COPYING in top-level directory. */
@@ -272,8 +273,7 @@ static int orangefs_inode_is_stale(struct inode *inode,return 0 ; } -int orangefs_inode_getattr (struct inode *inode,int new,int bypass, -u32 request_mask) +int orangefs_inode_getattr (struct inode *inode,int flags) {struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode);struct orangefs_kernel_op_s *new_op;
@@ -283,16 +283,9 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: called on inode %pU\n" , __func__,get_khandle_from_ino (inode)); -if (!new && !bypass) { -/* -* Must have all the attributes in the mask and be within cache -* time. -*/ -if ((request_mask & orangefs_inode->getattr_mask) == - request_mask && -time_before (jiffies, orangefs_inode->getattr_time)) -return 0 ; - } +/* Must have all the attributes in the mask and be within cache time. */ +if (!flags &&time_before (jiffies, orangefs_inode->getattr_time)) +return 0 ; new_op =op_alloc (ORANGEFS_VFS_OP_GETATTR );if (!new_op)
@@ -302,7 +295,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,* Size is the hardest attribute to get. The incremental cost of any * other attribute is essentially zero. */ -if (request_mask &STATX_SIZE || new) +if (flags) new_op->upcall.req.getattr.mask =ORANGEFS_ATTR_SYS_ALL_NOHINT ;else new_op->upcall.req.getattr.mask =
@@ -313,7 +306,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,if (ret !=0 ) goto out; -if (!new) { +if (!(flags &ORANGEFS_GETATTR_NEW )) { ret =orangefs_inode_is_stale (inode, &new_op->downcall.resp.getattr.attributes, new_op->downcall.resp.getattr.link_target);
@@ -329,7 +322,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,case S_IFREG : inode->i_flags =orangefs_inode_flags (&new_op-> downcall.resp.getattr.attributes); -if (request_mask &STATX_SIZE || new) { +if (flags) { inode_size = (loff_t )new_op-> downcall.resp.getattr.attributes.size; inode->i_size = inode_size;
@@ -343,7 +336,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, }break ;case S_IFDIR : -if (request_mask &STATX_SIZE || new) { +if (flags) { inode->i_size =PAGE_SIZE ;spin_lock (&inode->i_lock);inode_set_bytes (inode, inode->i_size);
@@ -352,7 +345,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,set_nlink (inode,1 );break ;case S_IFLNK : -if (new) { +if (flags &ORANGEFS_GETATTR_NEW ) { inode->i_size = (loff_t )strlen (new_op-> downcall.resp.getattr.link_target); ret = strscpy(orangefs_inode->link_target,
@@ -393,10 +386,6 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, orangefs_inode->getattr_time = jiffies + orangefs_getattr_timeout_msecs*HZ /1000 ; -if (request_mask &STATX_SIZE || new) - orangefs_inode->getattr_mask =STATX_BASIC_STATS ; -else - orangefs_inode->getattr_mask =STATX_BASIC_STATS & ~STATX_SIZE ; ret =0 ; out:op_release (new_op);
Signature · 1 line
2.20.1
PATCH 4/22 orangefs: update attributes rather than relying on server
In reply to [email protected]From: Martin Brandenburg <[email protected]>
This should be a no-op now, but once inode writeback works, it'll be necessary to have the correct attribute in the dirty inode.
Previously the attribute fetch timeout was marked invalid and the server provided the updated attribute. When the inode is dirty, the server cannot be consulted since it does not yet know the pending setattr.
--- fs/orangefs/file.c | 10 ++-------- fs/orangefs/namei.c | 7 ++++++- 2 files changed, 8 insertions(+), 9 deletions(-)
fs/orangefs/file.c +2 -8
@@ -327,14 +327,8 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file,file_accessed (file); }else {file_update_time (file); -/* -* Must invalidate to ensure write loop doesn't -* prevent kernel from reading updated -* attribute. Size probably changed because of -* the write, and other clients could update -* any other attribute. -*/ - orangefs_inode->getattr_time = jiffies -1 ; +if (*offset >i_size_read (inode)) +i_size_write (inode, *offset); } }
fs/orangefs/namei.c +6 -1
@@ -383,6 +383,7 @@ static int orangefs_rename(struct inode *old_dir, unsigned int flags) {struct orangefs_kernel_op_s *new_op; +struct iattr iattr;int ret;if (flags)
@@ -392,7 +393,11 @@ static int orangefs_rename(struct inode *old_dir,"orangefs_rename: called (%pd2 => %pd2) ct=%d\n" , old_dentry, new_dentry, d_count(new_dentry)); -ORANGEFS_I (new_dentry->d_parent->d_inode)->getattr_time = jiffies -1 ; + new_dir->i_mtime = new_dir->i_ctime =current_time (new_dir); +memset (&iattr,0 ,sizeof iattr); + iattr.ia_valid |=ATTR_MTIME ; +orangefs_inode_setattr (new_dir, &iattr); +mark_inode_dirty_sync (new_dir); new_op =op_alloc (ORANGEFS_VFS_OP_RENAME );if (!new_op)
Signature · 1 line
2.20.1
PATCH 5/22 orangefs: hold i_lock during inode_getattr
In reply to [email protected]From: Martin Brandenburg <[email protected]>
This should be a no-op now. When inode writeback works, this will prevent a getattr from overwriting inode data while an inode is transitioning to dirty.
--- fs/orangefs/inode.c | 4 ++-- fs/orangefs/orangefs-utils.c | 33 +++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-)
fs/orangefs/inode.c +2 -2
@@ -253,8 +253,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,struct inode *inode = path->dentry->d_inode;gossip_debug (GOSSIP_INODE_DEBUG , -"orangefs_getattr: called on %pd\n" , - path->dentry); +"orangefs_getattr: called on %pd mask %u\n" , + path->dentry, request_mask); ret =orangefs_inode_getattr (inode, request_mask &STATX_SIZE ?ORANGEFS_GETATTR_SIZE :0 );
fs/orangefs/orangefs-utils.c +23 -10
@@ -280,12 +280,17 @@ int orangefs_inode_getattr(struct inode *inode, int flags)loff_t inode_size;int ret, type; -gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: called on inode %pU\n" , __func__, -get_khandle_from_ino (inode)); +gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: called on inode %pU flags %d\n" , + __func__,get_khandle_from_ino (inode), flags); +spin_lock (&inode->i_lock);/* Must have all the attributes in the mask and be within cache time. */ -if (!flags &&time_before (jiffies, orangefs_inode->getattr_time)) +if ((!flags &&time_before (jiffies, orangefs_inode->getattr_time)) || + inode->i_state &I_DIRTY ) { +spin_unlock (&inode->i_lock);return 0 ; + } +spin_unlock (&inode->i_lock); new_op =op_alloc (ORANGEFS_VFS_OP_GETATTR );if (!new_op)
@@ -306,13 +311,23 @@ int orangefs_inode_getattr(struct inode *inode, int flags)if (ret !=0 ) goto out; +spin_lock (&inode->i_lock); +/* Must have all the attributes in the mask and be within cache time. */ +if ((!flags &&time_before (jiffies, orangefs_inode->getattr_time)) || + inode->i_state &I_DIRTY ) { +gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: in cache or dirty\n" , + __func__); + ret =0 ; + goto out_unlock; + } +if (!(flags &ORANGEFS_GETATTR_NEW )) { ret =orangefs_inode_is_stale (inode, &new_op->downcall.resp.getattr.attributes, new_op->downcall.resp.getattr.link_target);if (ret) { ret = -ESTALE ; - goto out; + goto out_unlock; } }
@@ -328,19 +343,15 @@ int orangefs_inode_getattr(struct inode *inode, int flags) inode->i_size = inode_size; inode->i_blkbits =ffs (new_op->downcall.resp.getattr. attributes.blksize); -spin_lock (&inode->i_lock); inode->i_bytes = inode_size; inode->i_blocks = (inode_size +512 - inode_size %512 )/512 ; -spin_unlock (&inode->i_lock); }break ;case S_IFDIR :if (flags) { inode->i_size =PAGE_SIZE ; -spin_lock (&inode->i_lock);inode_set_bytes (inode, inode->i_size); -spin_unlock (&inode->i_lock); }set_nlink (inode,1 );break ;
@@ -353,7 +364,7 @@ int orangefs_inode_getattr(struct inode *inode, int flags) ORANGEFS_NAME_MAX);if (ret == -E2BIG ) { ret = -EIO ; - goto out; + goto out_unlock; } inode->i_link = orangefs_inode->link_target; }
@@ -363,7 +374,7 @@ int orangefs_inode_getattr(struct inode *inode, int flags)/* XXX: ESTALE? This is what is done if it is not new. */ orangefs_make_bad_inode (inode); ret = -ESTALE ; - goto out; + goto out_unlock; } inode->i_uid = make_kuid(&init_user_ns, new_op->
@@ -387,6 +398,8 @@ int orangefs_inode_getattr(struct inode *inode, int flags) orangefs_inode->getattr_time = jiffies + orangefs_getattr_timeout_msecs*HZ /1000 ; ret =0 ; +out_unlock: +spin_unlock (&inode->i_lock); out:op_release (new_op);return ret;
Signature · 1 line
2.20.1
PATCH 6/22 orangefs: set up and use backing_dev_info
In reply to [email protected]From: Martin Brandenburg <[email protected]>
--- fs/orangefs/super.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
fs/orangefs/super.c +14 -7
@@ -407,15 +407,11 @@ static int orangefs_fill_sb(struct super_block *sb,struct orangefs_fs_mount_response *fs_mount, void *data, int silent) { - int ret = -EINVAL; -struct inode *root =NULL ; -struct dentry *root_dentry =NULL ; + int ret; +struct inode *root; +struct dentry *root_dentry;struct orangefs_object_kref root_object; -/* alloc and init our private orangefs sb info */ - sb->s_fs_info =kzalloc (sizeof (struct orangefs_sb_info_s ),GFP_KERNEL ); -if (!ORANGEFS_SB (sb)) -return -ENOMEM ;ORANGEFS_SB (sb)->sb = sb;ORANGEFS_SB (sb)->root_khandle = fs_mount->root_khandle;
@@ -438,6 +434,10 @@ static int orangefs_fill_sb(struct super_block *sb, sb->s_blocksize_bits =PAGE_SHIFT ; sb->s_maxbytes =MAX_LFS_FILESIZE ; + ret =super_setup_bdi (sb); +if (ret) +return ret; + root_object.khandle =ORANGEFS_SB (sb)->root_khandle; root_object.fs_id =ORANGEFS_SB (sb)->fs_id; gossip_debug(GOSSIP_SUPER_DEBUG,
@@ -516,6 +516,13 @@ struct dentry *orangefs_mount(struct file_system_type *fst, goto free_op; } +/* alloc and init our private orangefs sb info */ + sb->s_fs_info =kzalloc (sizeof (struct orangefs_sb_info_s ),GFP_KERNEL ); +if (!ORANGEFS_SB (sb)) { + d =ERR_PTR (-ENOMEM ); + goto free_op; + } + ret =orangefs_fill_sb (sb, &new_op->downcall.resp.fs_mount, data, flags &SB_SILENT ?1 :0 );
Signature · 1 line
2.20.1
PATCH 7/22 orangefs: let setattr write to cached inode
In reply to [email protected]From: Martin Brandenburg <[email protected]>
This is a fairly big change, but ultimately it's not a lot of code.
Implement write_inode and then avoid the call to orangefs_inode_setattr within orangefs_setattr.
--- fs/orangefs/inode.c | 11 +++-------- fs/orangefs/super.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-)
fs/orangefs/inode.c +3 -8
@@ -207,8 +207,8 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr)*/ int orangefs_setattr (struct dentry *dentry,struct iattr *iattr) { -int ret = -EINVAL ;struct inode *inode = dentry->d_inode; +int ret; gossip_debug(GOSSIP_INODE_DEBUG, "%s: called on %pd\n",
@@ -228,16 +228,11 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr)setattr_copy (inode, iattr);mark_inode_dirty (inode); - ret =orangefs_inode_setattr (inode, iattr); -gossip_debug (GOSSIP_INODE_DEBUG , -"%s: orangefs_inode_setattr returned %d\n" , - __func__, - ret); - -if (!ret && (iattr->ia_valid &ATTR_MODE )) +if (iattr->ia_valid &ATTR_MODE )/* change mod on a file that has ACLs */ ret =posix_acl_chmod (inode, inode->i_mode); + ret =0 ; out:gossip_debug (GOSSIP_INODE_DEBUG ,"%s: ret:%d:\n" , __func__, ret);return ret;
fs/orangefs/super.c +17 -0
@@ -152,6 +152,22 @@ static void orangefs_destroy_inode(struct inode *inode)call_rcu (&inode->i_rcu, orangefs_i_callback); } +static int orangefs_write_inode (struct inode *inode, +struct writeback_control *wbc) +{ +struct iattr iattr; +gossip_debug (GOSSIP_SUPER_DEBUG ,"orangefs_write_inode\n" ); + iattr.ia_valid =ATTR_MODE |ATTR_UID |ATTR_GID |ATTR_ATIME | +ATTR_ATIME_SET |ATTR_MTIME |ATTR_MTIME_SET |ATTR_CTIME ; + iattr.ia_mode = inode->i_mode; + iattr.ia_uid = inode->i_uid; + iattr.ia_gid = inode->i_gid; + iattr.ia_atime = inode->i_atime; + iattr.ia_mtime = inode->i_mtime; + iattr.ia_ctime = inode->i_ctime; +return orangefs_inode_setattr (inode, &iattr); +} +/* * NOTE: information filled in here is typically reflected in the * output of the system command 'df'
@@ -310,6 +326,7 @@ void fsid_key_table_finalize(void)static const struct super_operations orangefs_s_ops = { .alloc_inode = orangefs_alloc_inode, .destroy_inode = orangefs_destroy_inode, + .write_inode = orangefs_write_inode, .drop_inode = generic_delete_inode, .statfs = orangefs_statfs, .remount_fs = orangefs_remount_fs,
Signature · 1 line
2.20.1
PATCH 10/22 orangefs: service ops done for writeback are not killable
In reply to [email protected]From: Martin Brandenburg <[email protected]>
--- fs/orangefs/orangefs-kernel.h | 1 + fs/orangefs/orangefs-utils.c | 2 +- fs/orangefs/waitqueue.c | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-)
fs/orangefs/orangefs-kernel.h +1 -0
@@ -442,6 +442,7 @@ extern const struct dentry_operations orangefs_dentry_operations;#define ORANGEFS_OP_CANCELLATION 4/* this is a cancellation */ #define ORANGEFS_OP_NO_MUTEX 8/* don't acquire request_mutex */ #define ORANGEFS_OP_ASYNC 16/* Queue it, but don't wait */ +#define ORANGEFS_OP_WRITEBACK 32 int service_operation(struct orangefs_kernel_op_s *op, const char *op_name,
fs/orangefs/orangefs-utils.c +1 -1
@@ -430,7 +430,7 @@ int orangefs_inode_setattr(struct inode *inode)spin_unlock (&inode->i_lock); ret =service_operation (new_op, __func__, -get_interruptible_flag (inode)); +get_interruptible_flag (inode) |ORANGEFS_OP_WRITEBACK );gossip_debug (GOSSIP_UTILS_DEBUG ,"orangefs_inode_setattr: returning %d\n" , ret);if (ret)
fs/orangefs/waitqueue.c +10 -8
@@ -19,7 +19,7 @@ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op, long timeout, - bool interruptible) + int flags) __acquires(op->lock); static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *op) __releases(op->lock);
@@ -143,9 +143,7 @@ int service_operation(struct orangefs_kernel_op_s *op,if (!(flags &ORANGEFS_OP_NO_MUTEX ))mutex_unlock (&orangefs_request_mutex); - ret =wait_for_matching_downcall (op, timeout, - flags &ORANGEFS_OP_INTERRUPTIBLE ); - + ret =wait_for_matching_downcall (op, timeout, flags); gossip_debug(GOSSIP_WAIT_DEBUG, "%s: wait_for_matching_downcall returned %d for %p\n", __func__,
@@ -319,10 +317,12 @@ static void*/ static int wait_for_matching_downcall (struct orangefs_kernel_op_s *op,long timeout, -bool interruptible) +int flags) __acquires(op->lock) {long n; +int writeback = flags &ORANGEFS_OP_WRITEBACK , + interruptible = flags &ORANGEFS_OP_INTERRUPTIBLE ;/* * There's a "schedule_timeout" inside of these wait
@@ -330,10 +330,12 @@ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op,* user process that needs something done and is being * manipulated by the client-core process. */ -if (interruptible) +if (writeback) + n =wait_for_completion_io_timeout (&op->waitq, timeout); +else if (!writeback && interruptible) n =wait_for_completion_interruptible_timeout (&op->waitq, - timeout); -else + timeout); +else /* !writeback && !interruptible but compiler complains */ n =wait_for_completion_killable_timeout (&op->waitq, timeout);spin_lock (&op->lock);
Signature · 1 line
2.20.1
PATCH 8/22 orangefs: reorganize setattr functions to track attribute changes
In reply to [email protected]From: Martin Brandenburg <[email protected]>
OrangeFS accepts a mask indicating which attributes were changed. The kernel must not set any bits except those that were actually changed. The kernel must set the uid/gid of the request to the actual uid/gid responsible for the change.
Code path for notify_change initiated setattrs is
orangefs_setattr(dentry, iattr)
-> __orangefs_setattr(inode, iattr)
In kernel changes are initiated by calling __orangefs_setattr.
Code path for writeback is
orangefs_write_inode
-> orangefs_inode_setattr
attr_valid and attr_uid and attr_gid change together under i_lock. I_DIRTY changes separately.
__orangefs_setattr
lock
if needs to be cleaned first, unlock and retry set attr_valid
copy data in
unlock
mark_inode_dirty
orangefs_inode_setattr
lock
copy attributes out
unlock
clear getattr_time
# __writeback_single_inode clears dirty
orangefs_inode_getattr
# possible to get here with attr_valid set and not dirty lock if getattr_time ok or attr_valid set, unlock and return unlock do server operation # another thread may getattr or setattr, so check for that lock if getattr_time ok or attr_valid, unlock and return else, copy in update getattr_time unlock
--- fs/orangefs/acl.c | 4 +- fs/orangefs/inode.c | 76 ++++++++++++++++++----- fs/orangefs/namei.c | 35 +++++------ fs/orangefs/orangefs-kernel.h | 8 ++- fs/orangefs/orangefs-utils.c | 114 +++++++++++++--------------------- fs/orangefs/super.c | 11 +--- 6 files changed, 129 insertions(+), 119 deletions(-)
fs/orangefs/acl.c +2 -2
@@ -142,7 +142,7 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) rc =__orangefs_set_acl (inode, acl, type); }else { iattr.ia_valid =ATTR_MODE ; - rc =orangefs_inode_setattr (inode, &iattr); + rc =__orangefs_setattr (inode, &iattr); }return rc;
@@ -185,7 +185,7 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir) inode->i_mode = mode; iattr.ia_mode = mode; iattr.ia_valid |=ATTR_MODE ; -orangefs_inode_setattr (inode, &iattr); +__orangefs_setattr (inode, &iattr); }return error;
fs/orangefs/inode.c +61 -15
116 lines not on this page · raw message
fs/orangefs/namei.c +15 -20
@@ -82,11 +82,10 @@ static int orangefs_create(struct inode *dir, __func__, dentry); - dir->i_mtime = dir->i_ctime =current_time (dir);memset (&iattr,0 ,sizeof iattr); - iattr.ia_valid |=ATTR_MTIME ; -orangefs_inode_setattr (dir, &iattr); -mark_inode_dirty_sync (dir); + iattr.ia_valid |=ATTR_MTIME |ATTR_CTIME ; + iattr.ia_mtime = iattr.ia_ctime =current_time (dir); +__orangefs_setattr (dir, &iattr); ret =0 ; out:op_release (new_op);
@@ -208,11 +207,10 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)if (!ret) {drop_nlink (inode); - dir->i_mtime = dir->i_ctime =current_time (dir);memset (&iattr,0 ,sizeof iattr); - iattr.ia_valid |=ATTR_MTIME ; -orangefs_inode_setattr (dir, &iattr); -mark_inode_dirty_sync (dir); + iattr.ia_valid |=ATTR_MTIME |ATTR_CTIME ; + iattr.ia_mtime = iattr.ia_ctime =current_time (dir); +__orangefs_setattr (dir, &iattr); }return ret; }
@@ -295,11 +293,10 @@ static int orangefs_symlink(struct inode *dir,get_khandle_from_ino (inode), dentry); - dir->i_mtime = dir->i_ctime =current_time (dir);memset (&iattr,0 ,sizeof iattr); - iattr.ia_valid |=ATTR_MTIME ; -orangefs_inode_setattr (dir, &iattr); -mark_inode_dirty_sync (dir); + iattr.ia_valid |=ATTR_MTIME |ATTR_CTIME ; + iattr.ia_mtime = iattr.ia_ctime =current_time (dir); +__orangefs_setattr (dir, &iattr); ret =0 ; out:op_release (new_op);
@@ -366,11 +363,10 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode* NOTE: we have no good way to keep nlink consistent for directories * across clients; keep constant at 1. */ - dir->i_mtime = dir->i_ctime =current_time (dir);memset (&iattr,0 ,sizeof iattr); - iattr.ia_valid |=ATTR_MTIME ; -orangefs_inode_setattr (dir, &iattr); -mark_inode_dirty_sync (dir); + iattr.ia_valid |=ATTR_MTIME |ATTR_CTIME ; + iattr.ia_mtime = iattr.ia_ctime =current_time (dir); +__orangefs_setattr (dir, &iattr); out:op_release (new_op);return ret;
@@ -393,11 +389,10 @@ static int orangefs_rename(struct inode *old_dir,"orangefs_rename: called (%pd2 => %pd2) ct=%d\n" , old_dentry, new_dentry, d_count(new_dentry)); - new_dir->i_mtime = new_dir->i_ctime =current_time (new_dir);memset (&iattr,0 ,sizeof iattr); - iattr.ia_valid |=ATTR_MTIME ; -orangefs_inode_setattr (new_dir, &iattr); -mark_inode_dirty_sync (new_dir); + iattr.ia_valid |=ATTR_MTIME |ATTR_CTIME ; + iattr.ia_mtime = iattr.ia_ctime =current_time (new_dir); +__orangefs_setattr (new_dir, &iattr); new_op =op_alloc (ORANGEFS_VFS_OP_RENAME );if (!new_op)
fs/orangefs/orangefs-kernel.h +6 -2
@@ -193,6 +193,9 @@ struct orangefs_inode_s {sector_t last_failed_block_index_read;unsigned long getattr_time; +int attr_valid; +kuid_t attr_uid; +kgid_t attr_gid;DECLARE_HASHTABLE (xattr_cache,4 ); };
@@ -345,7 +348,8 @@ struct inode *orangefs_new_inode(struct super_block *sb,dev_t dev, struct orangefs_object_kref *ref); -int orangefs_setattr (struct dentry *dentry,struct iattr *iattr); +int __orangefs_setattr (struct inode *,struct iattr *); +int orangefs_setattr (struct dentry *,struct iattr *);int orangefs_getattr (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);
@@ -403,7 +407,7 @@ int orangefs_inode_getattr(struct inode *, int);int orangefs_inode_check_changed (struct inode *inode); -int orangefs_inode_setattr (struct inode *inode,struct iattr *iattr); +int orangefs_inode_setattr (struct inode *inode);bool orangefs_cancel_op_in_progress (struct orangefs_kernel_op_s *op);
fs/orangefs/orangefs-utils.c +44 -70
182 lines not on this page · raw message
fs/orangefs/super.c +1 -10
@@ -155,17 +155,8 @@ static void orangefs_destroy_inode(struct inode *inode)static int orangefs_write_inode (struct inode *inode,struct writeback_control *wbc) { -struct iattr iattr;gossip_debug (GOSSIP_SUPER_DEBUG ,"orangefs_write_inode\n" ); - iattr.ia_valid =ATTR_MODE |ATTR_UID |ATTR_GID |ATTR_ATIME | -ATTR_ATIME_SET |ATTR_MTIME |ATTR_MTIME_SET |ATTR_CTIME ; - iattr.ia_mode = inode->i_mode; - iattr.ia_uid = inode->i_uid; - iattr.ia_gid = inode->i_gid; - iattr.ia_atime = inode->i_atime; - iattr.ia_mtime = inode->i_mtime; - iattr.ia_ctime = inode->i_ctime; -return orangefs_inode_setattr (inode, &iattr); +return orangefs_inode_setattr (inode); }/*
Signature · 1 line
2.20.1
PATCH 11/22 orangefs: migrate to generic_file_read_iter
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Remove orangefs_inode_read. It was used by readpage. Calling wait_for_direct_io directly serves the purpose just as well. There is now no check of the bufmap size in the readpage path. There are already other places the bufmap size is assumed to be greater than PAGE_SIZE.
Important to call truncate_inode_pages now in the write path so a subsequent read sees the new data.
--- fs/orangefs/file.c | 66 ++++------------------------------- fs/orangefs/inode.c | 63 ++++++++++++--------------------- fs/orangefs/orangefs-kernel.h | 13 ++++--- 3 files changed, 38 insertions(+), 104 deletions(-)
fs/orangefs/file.c +7 -59
@@ -44,7 +44,7 @@ static int flush_racache(struct inode *inode)/* * Post and wait for the I/O upcall to finish */ -static ssize_t wait_for_direct_io (enum ORANGEFS_io_type type,struct inode *inode, +ssize_t wait_for_direct_io (enum ORANGEFS_io_type type,struct inode *inode,loff_t *offset,struct iov_iter *iter,size_t total_size,loff_t readahead_size) {
@@ -240,7 +240,7 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod* augmented/extended metadata attached to the file. * Note: File extended attributes override any mount options. */ -static ssize_t do_readv_writev (enum ORANGEFS_io_type type,struct file *file, +ssize_t do_readv_writev (enum ORANGEFS_io_type type,struct file *file,loff_t *offset,struct iov_iter *iter) {struct inode *inode = file->f_mapping->host;
@@ -341,65 +341,11 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file,return ret; } -/* -* Read data from a specified offset in a file (referenced by inode). -* Data may be placed either in a user or kernel buffer. -*/ -ssize_t orangefs_inode_read (struct inode *inode, -struct iov_iter *iter, -loff_t *offset, -loff_t readahead_size) +static ssize_t orangefs_file_read_iter (struct kiocb *iocb, +struct iov_iter *iter) { -struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode); -size_t count =iov_iter_count (iter); -size_t bufmap_size; -ssize_t ret = -EINVAL ; - orangefs_stats.reads++; - - bufmap_size =orangefs_bufmap_size_query (); -if (count > bufmap_size) { -gossip_debug (GOSSIP_FILE_DEBUG , -"%s: count is too large (%zd/%zd)!\n" , - __func__, count, bufmap_size); -return -EINVAL ; - } - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU) %zd@%llu\n" , - __func__, - &orangefs_inode->refn.khandle, - count, -llu (*offset)); - - ret =wait_for_direct_io (ORANGEFS_IO_READ , inode, offset, iter, - count, readahead_size); -if (ret >0 ) - *offset += ret; - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): Value(%zd) returned.\n" , - __func__, - &orangefs_inode->refn.khandle, - ret); - -return ret; -} - -static ssize_t orangefs_file_read_iter (struct kiocb *iocb,struct iov_iter *iter) -{ -struct file *file = iocb->ki_filp; -loff_t pos = iocb->ki_pos; -ssize_t rc =0 ; - -gossip_debug (GOSSIP_FILE_DEBUG ,"orangefs_file_read_iter\n" ); - - orangefs_stats.reads++; - - rc =do_readv_writev (ORANGEFS_IO_READ , file, &pos, iter); - iocb->ki_pos = pos; - -return rc; +return generic_file_read_iter (iocb, iter); }static ssize_t orangefs_file_write_iter (struct kiocb *iocb,struct iov_iter *iter)
@@ -408,6 +354,8 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iteloff_t pos;ssize_t rc; +truncate_inode_pages (file->f_mapping,0 ); +gossip_debug (GOSSIP_FILE_DEBUG ,"orangefs_file_write_iter\n" );inode_lock (file->f_mapping->host);
fs/orangefs/inode.c +23 -40
82 lines not on this page · raw message
fs/orangefs/orangefs-kernel.h +8 -5
@@ -369,11 +369,6 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size);struct inode *orangefs_iget (struct super_block *sb,struct orangefs_object_kref *ref); -ssize_t orangefs_inode_read (struct inode *inode, -struct iov_iter *iter, -loff_t *offset, -loff_t readahead_size); -/* * defined in devorangefs-req.c */
@@ -384,6 +379,14 @@ void orangefs_dev_cleanup(void);int is_daemon_in_service (void );bool __is_daemon_in_service (void ); +/* +* defined in file.c +*/ +ssize_t wait_for_direct_io (enum ORANGEFS_io_type ,struct inode *,loff_t *, +struct iov_iter *,size_t ,loff_t ); +ssize_t do_readv_writev (enum ORANGEFS_io_type ,struct file *,loff_t *, +struct iov_iter *); +/* * defined in orangefs-utils.c */
Signature · 1 line
2.20.1
PATCH 9/22 orangefs: remove orangefs_readpages
In reply to [email protected]From: Martin Brandenburg <[email protected]>
It's a copy of the loop which would run in read_pages from mm/readahead.c.
--- fs/orangefs/inode.c | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-)
fs/orangefs/inode.c +1 -38
@@ -15,7 +15,7 @@#include "orangefs-kernel.h" #include "orangefs-bufmap.h" -static int read_one_page (struct page *page) +static int orangefs_readpage (struct file *file,struct page *page) {int ret;int max_block;
@@ -60,42 +60,6 @@ static int read_one_page(struct page *page)return ret; } -static int orangefs_readpage (struct file *file,struct page *page) -{ -return read_one_page (page); -} - -static int orangefs_readpages (struct file *file, -struct address_space *mapping, -struct list_head *pages, -unsigned nr_pages) -{ -int page_idx; -int ret; - -gossip_debug (GOSSIP_INODE_DEBUG ,"orangefs_readpages called\n" ); - -for (page_idx =0 ; page_idx < nr_pages; page_idx++) { -struct page *page; - - page =lru_to_page (pages); -list_del (&page->lru); -if (!add_to_page_cache (page, - mapping, - page->index, -readahead_gfp_mask (mapping))) { - ret =read_one_page (page); -gossip_debug (GOSSIP_INODE_DEBUG , -"failure adding page to cache, read_one_page returned: %d\n" , - ret); - }else { -put_page (page); - } - } -BUG_ON (!list_empty (pages)); -return 0 ; -} -static void orangefs_invalidatepage (struct page *page,unsigned int offset,unsigned int length)
@@ -141,7 +105,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb,/** ORANGEFS2 implementation of address space operations */ static const struct address_space_operations orangefs_address_operations = { .readpage = orangefs_readpage, - .readpages = orangefs_readpages, .invalidatepage = orangefs_invalidatepage, .releasepage = orangefs_releasepage, .direct_IO = orangefs_direct_IO,
Signature · 1 line
2.20.1
PATCH 12/22 orangefs: implement writepage
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Now orangefs_inode_getattr fills from cache if an inode has dirty pages.
also if attr_valid and dirty pages and !flags, we spin on inode writeback before returning if pages still dirty after: should it be other way
--- fs/orangefs/file.c | 75 ++++++++---------------------------- fs/orangefs/inode.c | 65 ++++++++++++++++++++++++++++--- fs/orangefs/orangefs-utils.c | 8 +++- 3 files changed, 80 insertions(+), 68 deletions(-)
fs/orangefs/file.c +15 -60
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 /* * (C) 2001 Clemson University and The University of Chicago +* Copyright 2018 Omnibond Systems, L.L.C. * * See COPYING in top-level directory. */
@@ -348,63 +349,11 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb,return generic_file_read_iter (iocb, iter); } -static ssize_t orangefs_file_write_iter (struct kiocb *iocb,struct iov_iter *iter) +static ssize_t orangefs_file_write_iter (struct kiocb *iocb, +struct iov_iter *iter) { -struct file *file = iocb->ki_filp; -loff_t pos; -ssize_t rc; - -truncate_inode_pages (file->f_mapping,0 ); - -gossip_debug (GOSSIP_FILE_DEBUG ,"orangefs_file_write_iter\n" ); - -inode_lock (file->f_mapping->host); - -/* Make sure generic_write_checks sees an up to date inode size. */ -if (file->f_flags &O_APPEND ) { - rc =orangefs_inode_getattr (file->f_mapping->host, -ORANGEFS_GETATTR_SIZE ); -if (rc == -ESTALE ) - rc = -EIO ; -if (rc) { -gossip_err ("%s: orangefs_inode_getattr failed, " -"rc:%zd:.\n" , __func__, rc); - goto out; - } - } - - rc =generic_write_checks (iocb, iter); - -if (rc <=0 ) { -gossip_err ("%s: generic_write_checks failed, rc:%zd:.\n" , - __func__, rc); - goto out; - } - -/* -* if we are appending, generic_write_checks would have updated -* pos to the end of the file, so we will wait till now to set -* pos... -*/ - pos = iocb->ki_pos; - - rc =do_readv_writev (ORANGEFS_IO_WRITE , - file, - &pos, - iter); -if (rc <0 ) { -gossip_err ("%s: do_readv_writev failed, rc:%zd:.\n" , - __func__, rc); - goto out; - } - - iocb->ki_pos = pos; orangefs_stats.writes++; - -out: - -inode_unlock (file->f_mapping->host); -return rc; +return generic_file_write_iter (iocb, iter); }/*
@@ -499,9 +448,6 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma) (char *)file->f_path.dentry->d_name.name : (char *)"Unknown")); -if ((vma->vm_flags &VM_SHARED ) && (vma->vm_flags &VM_MAYWRITE )) -return -EINVAL ; -/* set the sequential readahead hint */ vma->vm_flags |=VM_SEQ_READ ; vma->vm_flags &= ~VM_RAND_READ ;
@@ -541,8 +487,6 @@ static int orangefs_file_release(struct inode *inode, struct file *file)gossip_debug (GOSSIP_INODE_DEBUG ,"flush_racache finished\n" ); } -truncate_inode_pages (file_inode (file)->i_mapping, -0 ); }return 0 ; }
@@ -560,6 +504,11 @@ static int orangefs_fsync(struct file *file,ORANGEFS_I (file_inode (file));struct orangefs_kernel_op_s *new_op =NULL ; + ret =filemap_write_and_wait_range (file_inode (file)->i_mapping, + start, end); +if (ret <0 ) +return ret; + new_op =op_alloc (ORANGEFS_VFS_OP_FSYNC );if (!new_op)return -ENOMEM ;
@@ -641,6 +590,11 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } +static int orangefs_flush (struct file *file,fl_owner_t id) +{ +return vfs_fsync (file,0 ); +} +/** ORANGEFS implementation of VFS file operations */ const struct file_operations orangefs_file_operations = { .llseek = orangefs_file_llseek,
@@ -650,6 +604,7 @@ const struct file_operations orangefs_file_operations = { .unlocked_ioctl = orangefs_ioctl, .mmap = orangefs_file_mmap, .open = generic_file_open, + .flush = orangefs_flush, .release = orangefs_file_release, .fsync = orangefs_fsync, };
fs/orangefs/inode.c +59 -6
88 lines not on this page · raw message
fs/orangefs/orangefs-utils.c +6 -2
@@ -247,7 +247,7 @@ int orangefs_inode_getattr(struct inode *inode, int flags)spin_lock (&inode->i_lock);/* Must have all the attributes in the mask and be within cache time. */ if ((!flags &&time_before (jiffies, orangefs_inode->getattr_time)) || - orangefs_inode->attr_valid) { + orangefs_inode->attr_valid || inode->i_state &I_DIRTY_PAGES ) {if (orangefs_inode->attr_valid) {spin_unlock (&inode->i_lock);write_inode_now (inode,1 );
@@ -281,12 +281,16 @@ int orangefs_inode_getattr(struct inode *inode, int flags)spin_lock (&inode->i_lock);/* Must have all the attributes in the mask and be within cache time. */ if ((!flags &&time_before (jiffies, orangefs_inode->getattr_time)) || - orangefs_inode->attr_valid) { + orangefs_inode->attr_valid || inode->i_state &I_DIRTY_PAGES ) {if (orangefs_inode->attr_valid) {spin_unlock (&inode->i_lock);write_inode_now (inode,1 ); goto again2; } +if (inode->i_state &I_DIRTY_PAGES ) { + ret =0 ; + goto out_unlock; + }gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: in cache or dirty\n" , __func__); ret =0 ;
Signature · 1 line
2.20.1
PATCH 15/22 orangefs: skip inode writeout if nothing to write
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Would happen if an inode is dirty but whatever happened is not something that can be written out to OrangeFS.
--- fs/orangefs/orangefs-utils.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/orangefs/orangefs-utils.c +5 -0
@@ -431,6 +431,11 @@ int orangefs_inode_setattr(struct inode *inode)copy_attributes_from_inode (inode, &new_op->upcall.req.setattr.attributes); orangefs_inode->attr_valid =0 ; +if (!new_op->upcall.req.setattr.attributes.mask) { +spin_unlock (&inode->i_lock); +op_release (new_op); +return 0 ; + }spin_unlock (&inode->i_lock); ret = service_operation(new_op, __func__,
Signature · 1 line
2.20.1
PATCH 13/22 orangefs: do not return successful read when the client-core disappeared
In reply to [email protected]From: Martin Brandenburg <[email protected]>
--- fs/orangefs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/orangefs/file.c +4 -1
@@ -169,7 +169,10 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,* trigger the write. */ case OP_VFS_STATE_INPROGR : - ret = total_size; +if (type ==ORANGEFS_IO_READ ) + ret = -EINTR ; +else + ret = total_size;break ;default : gossip_err("%s: unexpected op state :%d:.\n",
Signature · 1 line
2.20.1
PATCH 16/22 orangefs: avoid fsync service operation on flush
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Without this, an fsync call is sent to the server even if no data changed. This resulted in a rather severe (50%) performance regression under certain metadata-heavy workloads.
In the past, everything was direct IO. Nothing happend on a close call. An explicit fsync call would send an fsync request to the server which in turn fsynced the underlying file.
Now there are cached writes. Then fsync began writing out dirty pages in addition to making an fsync request to the server, and close began calling fsync.
With this commit, close only writes out dirty pages, and does not make the fsync request.
--- fs/orangefs/file.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
fs/orangefs/file.c +23 -1
@@ -487,7 +487,29 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)static int orangefs_flush (struct file *file,fl_owner_t id) { -return vfs_fsync (file,0 ); +/* +* This is vfs_fsync_range(file, 0, LLONG_MAX, 0) without the +* service_operation in orangefs_fsync. +* +* Do not send fsync to OrangeFS server on a close. Do send fsync +* on an explicit fsync call. This duplicates historical OrangeFS +* behavior. +*/ +struct inode *inode = file->f_mapping->host; +int r; + +if (inode->i_state &I_DIRTY_TIME ) { +spin_lock (&inode->i_lock); + inode->i_state &= ~I_DIRTY_TIME ; +spin_unlock (&inode->i_lock); +mark_inode_dirty_sync (inode); + } + + r =filemap_write_and_wait_range (file->f_mapping,0 ,LLONG_MAX ); +if (r >0 ) +return 0 ; +else +return r; }/** ORANGEFS implementation of VFS file operations */
Signature · 1 line
2.20.1
PATCH 17/22 orangefs: write range tracking
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Attach the actual range of bytes written to plus the responsible uid/gid to each dirty page. This information must be sent to the server when the page is written out.
Now write_begin, page_mkwrite, and invalidatepage keep up with this information. There are several conditions where they must write out the page immediately to store the new range. Two non-contiguous ranges cannot be stored on a single page.
--- fs/orangefs/file.c | 10 +- fs/orangefs/inode.c | 289 ++++++++++++++++++++++++++++++---- fs/orangefs/orangefs-kernel.h | 10 +- 3 files changed, 274 insertions(+), 35 deletions(-)
fs/orangefs/file.c +7 -3
@@ -46,8 +46,8 @@ static int flush_racache(struct inode *inode)* Post and wait for the I/O upcall to finish */ ssize_t wait_for_direct_io (enum ORANGEFS_io_type type,struct inode *inode, -loff_t *offset,struct iov_iter *iter, -size_t total_size,loff_t readahead_size) +loff_t *offset,struct iov_iter *iter,size_t total_size, +loff_t readahead_size,struct orangefs_write_range *wr) {struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode);struct orangefs_khandle *handle = &orangefs_inode->refn.khandle;
@@ -85,6 +85,10 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, new_op->upcall.req.io.buf_index = buffer_index; new_op->upcall.req.io.count = total_size; new_op->upcall.req.io.offset = *offset; +if (type ==ORANGEFS_IO_WRITE && wr) { + new_op->upcall.uid =from_kuid (&init_user_ns, wr->uid); + new_op->upcall.gid =from_kgid (&init_user_ns, wr->gid); + } gossip_debug(GOSSIP_FILE_DEBUG, "%s(%pU): offset: %llu total_size: %zd\n",
@@ -329,7 +333,7 @@ static vm_fault_t orangefs_fault(struct vm_fault *vmf)static const struct vm_operations_struct orangefs_file_vm_ops = { .fault = orangefs_fault, .map_pages = filemap_map_pages, - .page_mkwrite = filemap_page_mkwrite, + .page_mkwrite = orangefs_page_mkwrite, };/*
fs/orangefs/inode.c +258 -31
365 lines not on this page · raw message
fs/orangefs/orangefs-kernel.h +9 -1
@@ -230,6 +230,13 @@ struct orangefs_cached_xattr {unsigned long timeout; }; +struct orangefs_write_range { +loff_t pos; +size_t len; +kuid_t uid; +kgid_t gid; +}; +extern struct orangefs_stats orangefs_stats;/*
@@ -342,6 +349,7 @@ void fsid_key_table_finalize(void);/* * defined in inode.c */ +vm_fault_t orangefs_page_mkwrite (struct vm_fault *); struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, int mode,
@@ -383,7 +391,7 @@ bool __is_daemon_in_service(void);* defined in file.c */ ssize_t wait_for_direct_io (enum ORANGEFS_io_type ,struct inode *,loff_t *, -struct iov_iter *,size_t ,loff_t ); +struct iov_iter *,size_t ,loff_t ,struct orangefs_write_range *);ssize_t do_readv_writev (enum ORANGEFS_io_type ,struct file *,loff_t *,struct iov_iter *);
Signature · 1 line
2.20.1
PATCH 18/22 orangefs: implement writepages
In reply to [email protected]From: Martin Brandenburg <[email protected]>
Go through pages and look for a consecutive writable region. After finding a number of consecutive writable pages or when finding that the next page's dirty range is not contiguous and cannot be written as one request, send the write to the server.
The number of pages is determined by the client-core's buffer size.
--- fs/orangefs/file.c | 1 + 1 file changed, 1 insertion(+)
fs/orangefs/file.c +1 -0
@@ -386,6 +386,7 @@ static int orangefs_file_release(struct inode *inode, struct file *file)gossip_debug (GOSSIP_INODE_DEBUG ,"flush_racache finished\n" ); } + }return 0 ; }
Signature · 1 line
2.20.1
PATCH 14/22 orangefs: move do_readv_writev to direct_IO
In reply to [email protected]From: Martin Brandenburg <[email protected]>
direct_IO was the only caller and all direct_IO did was call it, so there's no use in having the code spread out into so many functions.
--- fs/orangefs/file.c | 108 ----------------------------------------- fs/orangefs/inode.c | 114 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 111 insertions(+), 111 deletions(-)
fs/orangefs/file.c +0 -108
@@ -237,114 +237,6 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,return ret; } -/* -* Common entry point for read/write/readv/writev -* This function will dispatch it to either the direct I/O -* or buffered I/O path depending on the mount options and/or -* augmented/extended metadata attached to the file. -* Note: File extended attributes override any mount options. -*/ -ssize_t do_readv_writev (enum ORANGEFS_io_type type,struct file *file, -loff_t *offset,struct iov_iter *iter) -{ -struct inode *inode = file->f_mapping->host; -struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode); -struct orangefs_khandle *handle = &orangefs_inode->refn.khandle; -size_t count =iov_iter_count (iter); -ssize_t total_count =0 ; -ssize_t ret = -EINVAL ; - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n" , - __func__, - handle, - (int )count); - -if (type ==ORANGEFS_IO_WRITE ) { -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): proceeding with offset : %llu, " -"size %d\n" , - __func__, - handle, -llu (*offset), - (int )count); - } - -if (count ==0 ) { - ret =0 ; - goto out; - } - -while (iov_iter_count (iter)) { -size_t each_count =iov_iter_count (iter); -size_t amt_complete; - -/* how much to transfer in this loop iteration */ -if (each_count >orangefs_bufmap_size_query ()) - each_count =orangefs_bufmap_size_query (); - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): size of each_count(%d)\n" , - __func__, - handle, - (int )each_count); -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): BEFORE wait_for_io: offset is %d\n" , - __func__, - handle, - (int )*offset); - - ret =wait_for_direct_io (type, inode, offset, iter, - each_count,0 ); -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): return from wait_for_io:%d\n" , - __func__, - handle, - (int )ret); - -if (ret <0 ) - goto out; - - *offset += ret; - total_count += ret; - amt_complete = ret; - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): AFTER wait_for_io: offset is %d\n" , - __func__, - handle, - (int )*offset); - -/* -* if we got a short I/O operations, -* fall out and return what we got so far -*/ -if (amt_complete < each_count) -break ; - }/*end while */ - -out: -if (total_count >0 ) - ret = total_count; -if (ret >0 ) { -if (type ==ORANGEFS_IO_READ ) { -file_accessed (file); - }else { -file_update_time (file); -if (*offset >i_size_read (inode)) -i_size_write (inode, *offset); - } - } - -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): Value(%d) returned.\n" , - __func__, - handle, - (int )ret); - -return ret; -} -static ssize_t orangefs_file_read_iter (struct kiocb *iocb,struct iov_iter *iter) {
fs/orangefs/inode.c +111 -3
121 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 19/22 orangefs: add orangefs_revalidate_mapping
In reply to [email protected]From: Martin Brandenburg <[email protected]>
This is modeled after NFS, except our method is different. We use a simple timer to determine whether to invalidate the page cache. This is bound to perform.
This addes a sysfs parameter cache_timeout_msecs which controls the time between page cache invalidations.
--- fs/orangefs/file.c | 70 +++++++++- fs/orangefs/inode.c | 250 +++++++++++++++++++++++++++++++--- fs/orangefs/orangefs-kernel.h | 4 + fs/orangefs/orangefs-mod.c | 1 + fs/orangefs/orangefs-sysfs.c | 22 +++ 5 files changed, 328 insertions(+), 19 deletions(-)
fs/orangefs/file.c +68 -2
@@ -241,18 +241,78 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,return ret; } +int orangefs_revalidate_mapping (struct inode *inode) +{ +struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode); +struct address_space *mapping = inode->i_mapping; +unsigned long *bitlock = &orangefs_inode->bitlock; +int ret; + +while (1 ) { + ret =wait_on_bit (bitlock,1 ,TASK_KILLABLE ); +if (ret) +return ret; +spin_lock (&inode->i_lock); +if (test_bit (1 , bitlock)) { +spin_unlock (&inode->i_lock); +continue ; + } +if (!time_before (jiffies, orangefs_inode->mapping_time)) +break ; +spin_unlock (&inode->i_lock); +return 0 ; + } + +set_bit (1 , bitlock); +smp_wmb (); +spin_unlock (&inode->i_lock); + +unmap_mapping_range (mapping,0 ,0 ,0 ); + ret =filemap_write_and_wait (mapping); +if (!ret) + ret =invalidate_inode_pages2 (mapping); + + orangefs_inode->mapping_time = jiffies + + orangefs_cache_timeout_msecs*HZ /1000 ; + +clear_bit (1 , bitlock); +smp_mb__after_atomic (); +wake_up_bit (bitlock,1 ); + +return ret; +} +static ssize_t orangefs_file_read_iter (struct kiocb *iocb,struct iov_iter *iter) { +int ret; orangefs_stats.reads++; -return generic_file_read_iter (iocb, iter); + +down_read (&file_inode (iocb->ki_filp)->i_rwsem); + ret =orangefs_revalidate_mapping (file_inode (iocb->ki_filp)); +if (ret) + goto out; + + ret =generic_file_read_iter (iocb, iter); +out: +up_read (&file_inode (iocb->ki_filp)->i_rwsem); +return ret; }static ssize_t orangefs_file_write_iter (struct kiocb *iocb,struct iov_iter *iter) { +int ret; orangefs_stats.writes++; -return generic_file_write_iter (iocb, iter); + +if (iocb->ki_pos >i_size_read (file_inode (iocb->ki_filp))) { + ret =orangefs_revalidate_mapping (file_inode (iocb->ki_filp)); +if (ret) +return ret; + } + + ret =generic_file_write_iter (iocb, iter); +return ret; }/*
@@ -341,6 +401,12 @@ static const struct vm_operations_struct orangefs_file_vm_ops = {*/ static int orangefs_file_mmap (struct file *file,struct vm_area_struct *vma) { +int ret; + + ret =orangefs_revalidate_mapping (file_inode (file)); +if (ret) +return ret; + gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_mmap: called on %s\n", (file ?
fs/orangefs/inode.c +233 -17
370 lines not on this page · raw message
fs/orangefs/orangefs-kernel.h +4 -0
@@ -193,9 +193,11 @@ struct orangefs_inode_s {sector_t last_failed_block_index_read;unsigned long getattr_time; +unsigned long mapping_time;int attr_valid;kuid_t attr_uid;kgid_t attr_gid; +unsigned long bitlock;DECLARE_HASHTABLE (xattr_cache,4 ); };
@@ -390,6 +392,7 @@ bool __is_daemon_in_service(void);/* * defined in file.c */ +int orangefs_revalidate_mapping (struct inode *);ssize_t wait_for_direct_io (enum ORANGEFS_io_type ,struct inode *,loff_t *,struct iov_iter *,size_t ,loff_t ,struct orangefs_write_range *); ssize_t do_readv_writev(enum ORANGEFS_io_type, struct file *, loff_t *,
@@ -427,6 +430,7 @@ int orangefs_normalize_to_errno(__s32 error_code);extern struct mutex orangefs_request_mutex;extern int op_timeout_secs;extern int slot_timeout_secs; +extern int orangefs_cache_timeout_msecs;extern int orangefs_dcache_timeout_msecs;extern int orangefs_getattr_timeout_msecs;extern struct list_head orangefs_superblocks;
fs/orangefs/orangefs-mod.c +1 -0
@@ -30,6 +30,7 @@ static ulong module_parm_debug_mask;__u64 orangefs_gossip_debug_mask;int op_timeout_secs =ORANGEFS_DEFAULT_OP_TIMEOUT_SECS ;int slot_timeout_secs =ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS ; +int orangefs_cache_timeout_msecs =50 ;int orangefs_dcache_timeout_msecs =50 ;int orangefs_getattr_timeout_msecs =50 ;
fs/orangefs/orangefs-sysfs.c +22 -0
@@ -62,6 +62,14 @@* Slots are requested and waited for, * the wait times out after slot_timeout_secs. * +* What: /sys/fs/orangefs/cache_timeout_msecs +* Date: Mar 2018 +* Contact: Martin Brandenburg <[email protected]> +* Description: +* Time in milliseconds between which +* orangefs_revalidate_mapping will invalidate the page +* cache. +* * What: /sys/fs/orangefs/dcache_timeout_msecs * Date: Jul 2016 * Contact: Martin Brandenburg <[email protected]>
@@ -221,6 +229,13 @@ static ssize_t sysfs_int_show(struct kobject *kobj,"%d\n" , slot_timeout_secs); goto out; + }else if (!strcmp (attr->attr.name, +"cache_timeout_msecs" )) { + rc =scnprintf (buf, +PAGE_SIZE , +"%d\n" , + orangefs_cache_timeout_msecs); + goto out; }else if (!strcmp (attr->attr.name,"dcache_timeout_msecs" )) { rc = scnprintf(buf,
@@ -277,6 +292,9 @@ static ssize_t sysfs_int_store(struct kobject *kobj, }else if (!strcmp (attr->attr.name,"slot_timeout_secs" )) { rc =kstrtoint (buf,0 , &slot_timeout_secs); goto out; + }else if (!strcmp (attr->attr.name,"cache_timeout_msecs" )) { + rc =kstrtoint (buf,0 , &orangefs_cache_timeout_msecs); + goto out; }else if (!strcmp (attr->attr.name,"dcache_timeout_msecs" )) { rc =kstrtoint (buf,0 , &orangefs_dcache_timeout_msecs); goto out;
@@ -818,6 +836,9 @@ static struct orangefs_attribute op_timeout_secs_attribute =static struct orangefs_attribute slot_timeout_secs_attribute =__ATTR (slot_timeout_secs,0664 , sysfs_int_show, sysfs_int_store); +static struct orangefs_attribute cache_timeout_msecs_attribute = +__ATTR (cache_timeout_msecs,0664 , sysfs_int_show, sysfs_int_store); +static struct orangefs_attribute dcache_timeout_msecs_attribute =__ATTR (dcache_timeout_msecs,0664 , sysfs_int_show, sysfs_int_store);
@@ -861,6 +882,7 @@ static struct orangefs_attribute perf_time_interval_secs_attribute =static struct attribute *orangefs_default_attrs[] = { &op_timeout_secs_attribute.attr, &slot_timeout_secs_attribute.attr, + &cache_timeout_msecs_attribute.attr, &dcache_timeout_msecs_attribute.attr, &getattr_timeout_msecs_attribute.attr, &readahead_count_attribute.attr,
Signature · 1 line
2.20.1
PATCH 20/22 orangefs: remember count when reading.
In reply to [email protected]From: Mike Marshall <[email protected]>
Orangefs wins when it can do IO on large (up to four meg) blocks at a time, and looses when it has to do tiny "small io" reads and writes. Accessing Orangefs through the pagecache with the kernel module helps with small io, both reading and writing, a great deal. Readpage generally tries to fetch a page (four k) at a time. We'll let users use "count" (as in read(2) or pread(2) for example) as a knob to control how much data they get from Orangefs at a time and we'll try to use the data to fill extra pagecache pages when we get to ->readpage, hopefully resulting in fewer calls to readpage and Orangefs userspace.
We need a way to remember how they set count so that we can still have it available when we get to ->readpage.
- We'll use file->private_data to keep track of "count". We'll wrap generic_file_open with orangefs_file_open and initialize private_data to NULL there.
- In ->read_iter we have access to both "count" and file, so we'll kmalloc some space onto file->private_data and store "count" there.
- We'll kfree file->private_data each time we visit ->flush and reinitialize it to NULL.
--- fs/orangefs/file.c | 26 +++++++++++++++++++++++++- fs/orangefs/orangefs-kernel.h | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-)
fs/orangefs/file.c +25 -1
@@ -286,8 +286,23 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) {int ret; +struct orangefs_read_options *ro; + orangefs_stats.reads++; +/* +* Remember how they set "count" in read(2) or pread(2) or whatever - +* users can use count as a knob to control orangefs io size and later +* we can try to help them fill as many pages as possible in readpage. +*/ +if (!iocb->ki_filp->private_data) { + iocb->ki_filp->private_data =kmalloc (sizeof *ro,GFP_KERNEL ); +if (!iocb->ki_filp->private_data) +return (ENOMEM ); + ro = iocb->ki_filp->private_data; + ro->blksiz = iter->count; + } +down_read (&file_inode (iocb->ki_filp)->i_rwsem); ret =orangefs_revalidate_mapping (file_inode (iocb->ki_filp));if (ret)
@@ -556,6 +571,12 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } +static int orangefs_file_open (struct inode * inode,struct file *file) +{ + file->private_data =NULL ; +return generic_file_open (inode, file); +} +static int orangefs_flush (struct file *file,fl_owner_t id) {/*
@@ -569,6 +590,9 @@ static int orangefs_flush(struct file *file, fl_owner_t id)struct inode *inode = file->f_mapping->host;int r; +kfree (file->private_data); + file->private_data =NULL ; +if (inode->i_state &I_DIRTY_TIME ) {spin_lock (&inode->i_lock); inode->i_state &= ~I_DIRTY_TIME ;
@@ -591,7 +615,7 @@ const struct file_operations orangefs_file_operations = { .lock = orangefs_lock, .unlocked_ioctl = orangefs_ioctl, .mmap = orangefs_file_mmap, - .open = generic_file_open, + .open = orangefs_file_open, .flush = orangefs_flush, .release = orangefs_file_release, .fsync = orangefs_fsync,
fs/orangefs/orangefs-kernel.h +4 -0
@@ -239,6 +239,10 @@ struct orangefs_write_range {kgid_t gid; }; +struct orangefs_read_options { +ssize_t blksiz; +}; +extern struct orangefs_stats orangefs_stats;/*
Signature · 1 line
2.20.1
PATCH 21/22 orangefs: pass slot index back to readpage.
In reply to [email protected]From: Mike Marshall <[email protected]>
When userspace deposits more than a page of data into the shared buffer, we'll need to know which slot it is in when we get back to readpage so that we can try to use the extra data to fill some extra pages.
--- fs/orangefs/file.c | 2 +- fs/orangefs/inode.c | 8 ++++---- fs/orangefs/orangefs-kernel.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
fs/orangefs/file.c +1 -1
@@ -47,7 +47,7 @@ static int flush_racache(struct inode *inode)*/ ssize_t wait_for_direct_io (enum ORANGEFS_io_type type,struct inode *inode,loff_t *offset,struct iov_iter *iter,size_t total_size, -loff_t readahead_size,struct orangefs_write_range *wr) +loff_t readahead_size,struct orangefs_write_range *wr,int *index_return) {struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode);struct orangefs_khandle *handle = &orangefs_inode->refn.khandle;
fs/orangefs/inode.c +4 -4
@@ -55,7 +55,7 @@ static int orangefs_writepage_locked(struct page *page,iov_iter_bvec (&iter,WRITE , &bv,1 , wlen); ret =wait_for_direct_io (ORANGEFS_IO_WRITE , inode, &off, &iter, wlen, - len, wr); + len, wr,NULL );if (ret <0 ) {SetPageError (page);mapping_set_error (page->mapping, ret);
@@ -126,7 +126,7 @@ static int orangefs_writepages_work(struct orangefs_writepages *ow, wr.uid = ow->uid; wr.gid = ow->gid; ret =wait_for_direct_io (ORANGEFS_IO_WRITE , inode, &off, &iter, ow->len, -0 , &wr); +0 , &wr,NULL );if (ret <0 ) {for (i =0 ; i < ow->npages; i++) {SetPageError (ow->pages[i]);
@@ -265,7 +265,7 @@ static int orangefs_readpage(struct file *file, struct page *page)orangefs_launder_page (page); ret =wait_for_direct_io (ORANGEFS_IO_READ , inode, &off, &iter, -PAGE_SIZE , inode->i_size,NULL ); +PAGE_SIZE , inode->i_size,NULL ,NULL );/* this will only zero remaining unread portions of the page data */ iov_iter_zero (~0U , &iter);/* takes care of potential aliasing */
@@ -552,7 +552,7 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, (int)*offset); ret =wait_for_direct_io (type, inode, offset, iter, - each_count,0 ,NULL ); + each_count,0 ,NULL ,NULL ); gossip_debug(GOSSIP_FILE_DEBUG, "%s(%pU): return from wait_for_io:%d\n", __func__,
fs/orangefs/orangefs-kernel.h +1 -1
@@ -398,7 +398,7 @@ bool __is_daemon_in_service(void);*/ int orangefs_revalidate_mapping (struct inode *);ssize_t wait_for_direct_io (enum ORANGEFS_io_type ,struct inode *,loff_t *, -struct iov_iter *,size_t ,loff_t ,struct orangefs_write_range *); +struct iov_iter *,size_t ,loff_t ,struct orangefs_write_range *,int *);ssize_t do_readv_writev (enum ORANGEFS_io_type ,struct file *,loff_t *,struct iov_iter *);
Signature · 1 line
2.20.1
PATCH 22/22 orangefs: copy Orangefs-sized blocks into the pagecache if possible.
In reply to [email protected]From: Mike Marshall <[email protected]>
->readpage looks in file->private_data to try and find out how the userspace program set "count" in read(2) or with "dd bs=" or whatever.
->readpage uses "count" and inode->i_size to calculate how much data Orangefs should deposit in the Orangefs shared buffer, and remembers which slot the data is in.
After copying data from the Orangefs shared buffer slot into "the page", readpage tries to increment through the pagecache index and fill as many pages as it can from the extra data in the shared buffer. Hopefully these extra pages will soon be needed by the vfs, and they'll be in the pagecache already.
--- fs/orangefs/file.c | 37 +++++++++-- fs/orangefs/inode.c | 115 ++++++++++++++++++++++++++++++--- fs/orangefs/orangefs-bufmap.c | 13 ++++ fs/orangefs/orangefs-bufmap.h | 2 + fs/orangefs/orangefs-debugfs.c | 4 +- 5 files changed, 156 insertions(+), 15 deletions(-)
fs/orangefs/file.c +32 -5
@@ -54,6 +54,7 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,struct orangefs_kernel_op_s *new_op =NULL ;int buffer_index =-1 ;ssize_t ret; +size_t copy_amount; new_op =op_alloc (ORANGEFS_VFS_OP_FILE_IO );if (!new_op)
@@ -212,8 +213,25 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,* can futher be kernel-space or user-space addresses. * or it can pointers to struct page's */ + +/* +* When reading, readahead_size will only be zero when +* we're doing O_DIRECT, otherwise we got here from +* orangefs_readpage. +* +* If we got here from orangefs_readpage we want to +* copy either a page or the whole file into the io +* vector, whichever is smaller. +*/ +if (readahead_size) + copy_amount = +min (new_op->downcall.resp.io.amt_complete, + (__s64 )PAGE_SIZE ); +else + copy_amount = new_op->downcall.resp.io.amt_complete; + ret =orangefs_bufmap_copy_to_iovec (iter, buffer_index, - new_op->downcall.resp.io.amt_complete); + copy_amount);if (ret <0 ) {gossip_err ("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n" , __func__, (long )ret);
@@ -231,10 +249,19 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, out:if (buffer_index >=0 ) { -orangefs_bufmap_put (buffer_index); -gossip_debug (GOSSIP_FILE_DEBUG , -"%s(%pU): PUT buffer_index %d\n" , - __func__, handle, buffer_index); +if ((readahead_size) && (type ==ORANGEFS_IO_READ )) { +/* readpage */ + *index_return = buffer_index; +gossip_debug (GOSSIP_FILE_DEBUG , +"%s: hold on to buffer_index :%d:\n" , + __func__, buffer_index); + }else { +/* O_DIRECT */ +orangefs_bufmap_put (buffer_index); +gossip_debug (GOSSIP_FILE_DEBUG , +"%s(%pU): PUT buffer_index %d\n" , + __func__, handle, buffer_index); + } buffer_index =-1 ; }op_release (new_op);
fs/orangefs/inode.c +107 -8
156 lines not on this page · raw message
fs/orangefs/orangefs-bufmap.c +13 -0
@@ -538,3 +538,16 @@ int orangefs_bufmap_copy_to_iovec(struct iov_iter *iter, }return 0 ; } + +void orangefs_bufmap_page_fill (void *page_to, +int buffer_index, +int slot_index) +{ +struct orangefs_bufmap_desc *from; +void *page_from; + + from = &__orangefs_bufmap->desc_array[buffer_index]; + page_from =kmap_atomic (from->page_array[slot_index]); +memcpy (page_to, page_from,PAGE_SIZE ); +kunmap_atomic (page_from); +}
fs/orangefs/orangefs-bufmap.h +2 -0
@@ -34,4 +34,6 @@ int orangefs_bufmap_copy_to_iovec(struct iov_iter *iter,int buffer_index, size_t size); +void orangefs_bufmap_page_fill (void *kaddr,int buffer_index,int slot_index); +#endif /* __ORANGEFS_BUFMAP_H */
fs/orangefs/orangefs-debugfs.c +2 -2
@@ -963,7 +963,7 @@ int orangefs_debugfs_new_client_mask(void __user *arg)return ret; } -int orangefs_debugfs_new_client_string (void __user *arg) +int orangefs_debugfs_new_client_string (void __user *arg) {int ret;
@@ -1016,7 +1016,7 @@ int orangefs_debugfs_new_client_string(void __user *arg)return 0 ; } -int orangefs_debugfs_new_debug (void __user *arg) +int orangefs_debugfs_new_debug (void __user *arg) {struct dev_mask_info_s mask_info = {0 };int ret;
Signature · 1 line
2.20.1