orangefs: page cache
Subsystems (3)
Martin Brandenburg
reviewercover orangefs: page cache
This is significantly reworked from last time.
First some unrelated cleanups, which will in any case be submitted for 4.17.
Nothing too unusual here, but this is a big change, and it's time to get this out here.
Martin Brandenburg (24):
orangefs: make several *_operations structs static
orangefs: remove unused code
orangefs: create uapi interface
orangefs: open code short single-use functions
orangefs: implement vm_ops->fault
orangefs: implement xattr cache
orangefs: simpler installation documentation
orangefs: add tracepoint for service_operation
orangefs: tracepoints for orangefs_devreq_{read,write_iter,poll}
orangefs: do not invalidate attributes on inode create
orangefs: simply 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: skip inode writeout if nothing to write
orangefs: write range tracking
orangefs: tracepoints for readpage and writeback
orangefs: tracepoints for getattr, setattr, and write_inode
Documentation/filesystems/orangefs.txt | 84 ++-- fs/orangefs/Makefile | 4 +- fs/orangefs/acl.c | 5 +- fs/orangefs/dcache.c | 4 +- fs/orangefs/devorangefs-req.c | 66 +-- fs/orangefs/dir.c | 4 +- fs/orangefs/downcall.h | 137 ------ fs/orangefs/file.c | 295 ++++--------- fs/orangefs/inode.c | 471 +++++++++++++++------ fs/orangefs/namei.c | 54 ++- fs/orangefs/orangefs-bufmap.c | 1 - fs/orangefs/orangefs-cache.c | 1 - fs/orangefs/orangefs-debug.h | 33 -- fs/orangefs/orangefs-debugfs.c | 8 +- fs/orangefs/orangefs-dev-proto.h | 61 --- fs/orangefs/orangefs-kernel.h | 136 ++---- fs/orangefs/orangefs-mod.c | 1 - fs/orangefs/orangefs-sysfs.c | 12 +- fs/orangefs/orangefs-trace.c | 3 + fs/orangefs/orangefs-trace.h | 241 +++++++++++ fs/orangefs/orangefs-utils.c | 192 +++++---- fs/orangefs/protocol.h | 339 --------------- fs/orangefs/super.c | 50 ++- fs/orangefs/symlink.c | 1 - fs/orangefs/upcall.h | 260 ------------ fs/orangefs/waitqueue.c | 36 +- fs/orangefs/xattr.c | 112 ++++- include/uapi/linux/orangefs.h | 732 +++++++++++++++++++++++++++++++++ 28 files changed, 1825 insertions(+), 1518 deletions(-) delete mode 100644 fs/orangefs/downcall.h delete mode 100644 fs/orangefs/orangefs-dev-proto.h create mode 100644 fs/orangefs/orangefs-trace.c create mode 100644 fs/orangefs/orangefs-trace.h delete mode 100644 fs/orangefs/upcall.h create mode 100644 include/uapi/linux/orangefs.h
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 1/24 orangefs: make several *_operations structs static
--- fs/orangefs/devorangefs-req.c | 52 +++++++++++++++++++++---------------------- fs/orangefs/inode.c | 4 ++-- fs/orangefs/orangefs-kernel.h | 3 --- 3 files changed, 28 insertions(+), 31 deletions(-)
fs/orangefs/devorangefs-req.c +26 -26
@@ -779,9 +779,35 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd,#endif /* CONFIG_COMPAT is in .config */ +static __poll_t orangefs_devreq_poll (struct file *file, +struct poll_table_struct *poll_table) +{ +__poll_t poll_revent_mask =0 ; + +poll_wait (file, &orangefs_request_list_waitq, poll_table); + +if (!list_empty (&orangefs_request_list)) + poll_revent_mask |=EPOLLIN ; +return poll_revent_mask; +} +/* the assigned character device major number */ static int orangefs_dev_major; +static const struct file_operations orangefs_devreq_file_operations = { + .owner =THIS_MODULE , + .read = orangefs_devreq_read, + .write_iter = orangefs_devreq_write_iter, + .open = orangefs_devreq_open, + .release = orangefs_devreq_release, + .unlocked_ioctl = orangefs_devreq_ioctl, + +#ifdef CONFIG_COMPAT /* CONFIG_COMPAT is in .config */ + .compat_ioctl = orangefs_devreq_compat_ioctl, +#endif + .poll = orangefs_devreq_poll +}; +/* * Initialize orangefs device specific state: * Must be called at module load time only
@@ -814,29 +840,3 @@ void orangefs_dev_cleanup(void)"*** /dev/%s character device unregistered ***\n" , ORANGEFS_REQDEVICE_NAME); } - -static __poll_t orangefs_devreq_poll (struct file *file, -struct poll_table_struct *poll_table) -{ -__poll_t poll_revent_mask =0 ; - -poll_wait (file, &orangefs_request_list_waitq, poll_table); - -if (!list_empty (&orangefs_request_list)) - poll_revent_mask |=EPOLLIN ; -return poll_revent_mask; -} - -const struct file_operations orangefs_devreq_file_operations = { - .owner =THIS_MODULE , - .read = orangefs_devreq_read, - .write_iter = orangefs_devreq_write_iter, - .open = orangefs_devreq_open, - .release = orangefs_devreq_release, - .unlocked_ioctl = orangefs_devreq_ioctl, - -#ifdef CONFIG_COMPAT /* CONFIG_COMPAT is in .config */ - .compat_ioctl = orangefs_devreq_compat_ioctl, -#endif - .poll = orangefs_devreq_poll -};
fs/orangefs/inode.c +2 -2
@@ -138,7 +138,7 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, }/** ORANGEFS2 implementation of address space operations */ -const struct address_space_operations orangefs_address_operations = { +static const struct address_space_operations orangefs_address_operations = { .readpage = orangefs_readpage, .readpages = orangefs_readpages, .invalidatepage = orangefs_invalidatepage,
@@ -307,7 +307,7 @@ int orangefs_update_time(struct inode *inode, struct timespec *time, int flags) }/* ORANGEDS2 implementation of VFS inode operations for files */ -const struct inode_operations orangefs_file_inode_operations = { +static const struct inode_operations orangefs_file_inode_operations = { .get_acl = orangefs_get_acl, .set_acl = orangefs_set_acl, .setattr = orangefs_setattr,
fs/orangefs/orangefs-kernel.h +0 -3
@@ -487,14 +487,11 @@ extern struct list_head *orangefs_htable_ops_in_progress;extern spinlock_t orangefs_htable_ops_in_progress_lock;extern int hash_table_size; -extern const struct address_space_operations orangefs_address_operations; -extern const struct inode_operations orangefs_file_inode_operations;extern const struct file_operations orangefs_file_operations;extern const struct inode_operations orangefs_symlink_inode_operations;extern const struct inode_operations orangefs_dir_inode_operations;extern const struct file_operations orangefs_dir_operations;extern const struct dentry_operations orangefs_dentry_operations; -extern const struct file_operations orangefs_devreq_file_operations;extern wait_queue_head_t orangefs_bufmap_init_waitq;
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 2/24 orangefs: remove unused code
In reply to Martin Brandenburg--- fs/orangefs/orangefs-debug.h | 6 ---- fs/orangefs/orangefs-kernel.h | 77 ------------------------------------------- fs/orangefs/protocol.h | 45 ------------------------- 3 files changed, 128 deletions(-)
fs/orangefs/orangefs-debug.h +0 -6
@@ -43,12 +43,6 @@#define GOSSIP_MAX_NR 16#define GOSSIP_MAX_DEBUG (((__u64)1 << GOSSIP_MAX_NR) - 1) -/*function prototypes*/ -__u64 ORANGEFS_kmod_eventlog_to_mask (const char *event_logging); -__u64 ORANGEFS_debug_eventlog_to_mask (const char *event_logging); -char *ORANGEFS_debug_mask_to_eventlog (__u64 mask); -char *ORANGEFS_kmod_mask_to_eventlog (__u64 mask); -/* a private internal type */ struct __keyword_mask_s {const char *keyword;
fs/orangefs/orangefs-kernel.h +0 -77
126 lines not on this page · raw message
fs/orangefs/protocol.h +0 -45
69 lines not on this page · raw message
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 3/24 orangefs: create uapi interface
In reply to Martin BrandenburgThis formally separates userspace visible and kernel internal data structures. The sole consumer of this would be the pvfs2-client-core, which currently simply defines all these structures itself. Most of these are shared with the rest of the OrangeFS userspace client and server code.
As the userspace OrangeFS client and server progress, they are beginning to change their "internal" definitions. This will allow us to separate data structures which will be sent to the kernel and data structures which belong to userspace.
This is accomplished by moving everything relevant from fs/orangefs/*.h to include/uapi/linux/orangefs.h.
--- fs/orangefs/acl.c | 1 - fs/orangefs/dcache.c | 1 - fs/orangefs/devorangefs-req.c | 2 - fs/orangefs/dir.c | 1 - fs/orangefs/downcall.h | 137 -------- fs/orangefs/file.c | 1 - fs/orangefs/inode.c | 1 - fs/orangefs/namei.c | 1 - fs/orangefs/orangefs-bufmap.c | 1 - fs/orangefs/orangefs-cache.c | 1 - fs/orangefs/orangefs-debug.h | 27 -- fs/orangefs/orangefs-debugfs.c | 4 +- fs/orangefs/orangefs-dev-proto.h | 61 ---- fs/orangefs/orangefs-kernel.h | 3 +- fs/orangefs/orangefs-mod.c | 1 - fs/orangefs/orangefs-sysfs.c | 1 - fs/orangefs/orangefs-utils.c | 2 - fs/orangefs/protocol.h | 294 ---------------- fs/orangefs/super.c | 1 - fs/orangefs/symlink.c | 1 - fs/orangefs/upcall.h | 260 -------------- fs/orangefs/waitqueue.c | 1 - fs/orangefs/xattr.c | 1 - include/uapi/linux/orangefs.h | 732 +++++++++++++++++++++++++++++++++++++++ 24 files changed, 736 insertions(+), 800 deletions(-) delete mode 100644 fs/orangefs/downcall.h delete mode 100644 fs/orangefs/orangefs-dev-proto.h delete mode 100644 fs/orangefs/upcall.h create mode 100644 include/uapi/linux/orangefs.h
fs/orangefs/acl.c +0 -1
@@ -5,7 +5,6 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h" #include <linux/posix_acl_xattr.h>
fs/orangefs/dcache.c +0 -1
@@ -9,7 +9,6 @@* Implementation of dentry (directory cache) functions. */ -#include "protocol.h" #include "orangefs-kernel.h" /* Returns 1 if dentry can still be trusted, else 0. */
fs/orangefs/devorangefs-req.c +0 -2
@@ -8,9 +8,7 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" -#include "orangefs-dev-proto.h" #include "orangefs-bufmap.h" #include "orangefs-debugfs.h"
fs/orangefs/dir.c +0 -1
@@ -3,7 +3,6 @@* Copyright 2017 Omnibond Systems, L.L.C. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/downcall.h deleted +0 -137
137 lines not on this page · raw message
fs/orangefs/file.c +0 -1
@@ -9,7 +9,6 @@* Linux VFS file operations. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h" #include <linux/fs.h>
fs/orangefs/inode.c +0 -1
@@ -10,7 +10,6 @@*/ #include <linux/bvec.h> -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/namei.c +0 -1
@@ -9,7 +9,6 @@* Linux VFS namei operations. */ -#include "protocol.h" #include "orangefs-kernel.h" /*
fs/orangefs/orangefs-bufmap.c +0 -1
@@ -4,7 +4,6 @@* * See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/orangefs-cache.c +0 -1
@@ -5,7 +5,6 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" /* tags assigned to kernel upcall operations */
fs/orangefs/orangefs-debug.h +0 -27
@@ -13,35 +13,8 @@#ifndef __ORANGEFS_DEBUG_H#define __ORANGEFS_DEBUG_H -#ifdef __KERNEL__#include <linux/types.h> #include <linux/kernel.h> -#else -#include <stdint.h> -#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0])) -#endif - -#define GOSSIP_NO_DEBUG (__u64)0 - -#define GOSSIP_SUPER_DEBUG ((__u64)1 << 0) -#define GOSSIP_INODE_DEBUG ((__u64)1 << 1) -#define GOSSIP_FILE_DEBUG ((__u64)1 << 2) -#define GOSSIP_DIR_DEBUG ((__u64)1 << 3) -#define GOSSIP_UTILS_DEBUG ((__u64)1 << 4) -#define GOSSIP_WAIT_DEBUG ((__u64)1 << 5) -#define GOSSIP_ACL_DEBUG ((__u64)1 << 6) -#define GOSSIP_DCACHE_DEBUG ((__u64)1 << 7) -#define GOSSIP_DEV_DEBUG ((__u64)1 << 8) -#define GOSSIP_NAME_DEBUG ((__u64)1 << 9) -#define GOSSIP_BUFMAP_DEBUG ((__u64)1 << 10) -#define GOSSIP_CACHE_DEBUG ((__u64)1 << 11) -#define GOSSIP_DEBUGFS_DEBUG ((__u64)1 << 12) -#define GOSSIP_XATTR_DEBUG ((__u64)1 << 13) -#define GOSSIP_INIT_DEBUG ((__u64)1 << 14) -#define GOSSIP_SYSFS_DEBUG ((__u64)1 << 15) - -#define GOSSIP_MAX_NR 16 -#define GOSSIP_MAX_DEBUG (((__u64)1 << GOSSIP_MAX_NR) - 1)/* a private internal type */ struct __keyword_mask_s {
fs/orangefs/orangefs-debugfs.c +2 -2
@@ -40,9 +40,9 @@#include <linux/uaccess.h> -#include "orangefs-debugfs.h" -#include "protocol.h" #include "orangefs-kernel.h" +#include "orangefs-debug.h" +#include "orangefs-debugfs.h" #define DEBUG_HELP_STRING_SIZE 4096#define HELP_STRING_UNINITIALIZED \
fs/orangefs/orangefs-dev-proto.h deleted +0 -61
61 lines not on this page · raw message
fs/orangefs/orangefs-kernel.h +2 -1
@@ -54,7 +54,8 @@#include <asm/unaligned.h> -#include "orangefs-dev-proto.h" +#include <linux/orangefs.h> +#include "protocol.h" #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20
fs/orangefs/orangefs-mod.c +0 -1
@@ -7,7 +7,6 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-debugfs.h" #include "orangefs-sysfs.h"
fs/orangefs/orangefs-sysfs.c +0 -1
@@ -135,7 +135,6 @@#include <linux/module.h> #include <linux/init.h> -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-sysfs.h"
fs/orangefs/orangefs-utils.c +0 -2
@@ -5,9 +5,7 @@* See COPYING in top-level directory. */ #include <linux/kernel.h> -#include "protocol.h" #include "orangefs-kernel.h" -#include "orangefs-dev-proto.h" #include "orangefs-bufmap.h" __s32 fsid_of_op (struct orangefs_kernel_op_s *op)
fs/orangefs/protocol.h +0 -294
313 lines not on this page · raw message
fs/orangefs/super.c +0 -1
@@ -5,7 +5,6 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/symlink.c +0 -1
@@ -5,7 +5,6 @@* See COPYING in top-level directory. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/upcall.h deleted +0 -260
260 lines not on this page · raw message
fs/orangefs/waitqueue.c +0 -1
@@ -13,7 +13,6 @@* In-kernel waitqueue operations. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h"
fs/orangefs/xattr.c +0 -1
@@ -9,7 +9,6 @@* Linux VFS extended attribute operations. */ -#include "protocol.h" #include "orangefs-kernel.h" #include "orangefs-bufmap.h" #include <linux/posix_acl_xattr.h>
include/uapi/linux/orangefs.h new file +732 -0
732 lines not on this page · raw message
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 4/24 orangefs: open code short single-use functions
In reply to Martin Brandenburg--- fs/orangefs/file.c | 95 +++++++++++------------------------------------------- 1 file changed, 19 insertions(+), 76 deletions(-)
fs/orangefs/file.c +19 -76
@@ -40,70 +40,6 @@ static int flush_racache(struct inode *inode)return ret; } -/* -* Copy to client-core's address space from the buffers specified -* by the iovec upto total_size bytes. -* NOTE: the iovector can either contain addresses which -* can futher be kernel-space or user-space addresses. -* or it can pointers to struct page's -*/ -static int precopy_buffers (int buffer_index, -struct iov_iter *iter, -size_t total_size) -{ -int ret =0 ; -/* -* copy data from application/kernel by pulling it out -* of the iovec. -*/ - - -if (total_size) { - ret =orangefs_bufmap_copy_from_iovec (iter, - buffer_index, - total_size); -if (ret <0 ) -gossip_err ("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n" , - __func__, - (long )ret); - } - -if (ret <0 ) -gossip_err ("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n" , - __func__, - (long )ret); -return ret; -} - -/* -* Copy from client-core's address space to the buffers specified -* by the iovec upto total_size bytes. -* NOTE: the iovector can either contain addresses which -* can futher be kernel-space or user-space addresses. -* or it can pointers to struct page's -*/ -static int postcopy_buffers (int buffer_index, -struct iov_iter *iter, -size_t total_size) -{ -int ret =0 ; -/* -* copy data to application/kernel by pushing it out to -* the iovec. NOTE; target buffers can be addresses or -* struct page pointers. -*/ -if (total_size) { - ret =orangefs_bufmap_copy_to_iovec (iter, - buffer_index, - total_size); -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); - } -return ret; -} -/* * Post and wait for the I/O upcall to finish */
@@ -156,14 +92,15 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod total_size);/* * Stage 1: copy the buffers into client-core's address space -* precopy_buffers only pertains to writes. */ -if (type ==ORANGEFS_IO_WRITE ) { - ret =precopy_buffers (buffer_index, - iter, - total_size); -if (ret <0 ) +if (type ==ORANGEFS_IO_WRITE && total_size) { + ret =orangefs_bufmap_copy_from_iovec (iter, buffer_index, + total_size); +if (ret <0 ) { +gossip_err ("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n" , + __func__, (long )ret); goto out; + } } gossip_debug(GOSSIP_FILE_DEBUG,
@@ -259,14 +196,20 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod/* * Stage 3: Post copy buffers from client-core's address space -* postcopy_buffers only pertains to reads. */ -if (type ==ORANGEFS_IO_READ ) { - ret =postcopy_buffers (buffer_index, - iter, - new_op->downcall.resp.io.amt_complete); -if (ret <0 ) +if (type ==ORANGEFS_IO_READ && new_op->downcall.resp.io.amt_complete) { +/* +* NOTE: the iovector can either contain addresses which +* can futher be kernel-space or user-space addresses. +* or it can pointers to struct page's +*/ + ret =orangefs_bufmap_copy_to_iovec (iter, buffer_index, + new_op->downcall.resp.io.amt_complete); +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); goto out; + } } gossip_debug(GOSSIP_FILE_DEBUG, "%s(%pU): Amount %s, returned by the sys-io call:%d\n",
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 5/24 orangefs: implement vm_ops->fault
In reply to Martin BrandenburgMust retrieve size before running filemap_fault so the kernel has an up-to-date size.
This should have been caught by xfstests generic/246, but it was masked by orangefs_new_inode, which set i_size to PAGE_SIZE. When nothing caused a getattr prior to a pagefault, i_size was still PAGE_SIZE. Since xfstests only read 10 bytes, it did not catch this bug.
When orangefs_new_inode was modified to perform a getattr instead, i_size was set to zero, as it was a newly created file. Then orangefs_file_write_iter did NOT set i_size, instead prefering to invalidate the attribute cache and letting the next caller retrieve i_size. But the fault handler did not know it was supposed to retrieve i_size. So during xfstests, i_size was still zero, and filemap_fault returned VM_FAULT_SIGBUS.
Fixes xfstests generic/080, generic/141, generic/215, generic/247, generic/248, generic/437, and generic/452.
--- fs/orangefs/file.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
fs/orangefs/file.c +28 -2
@@ -527,6 +527,28 @@ static long orangefs_ioctl(struct file *file, unsigned int cmd, unsigned long arreturn ret; } +static int orangefs_fault (struct vm_fault *vmf) +{ +struct file *file = vmf->vma->vm_file; +int rc; + rc =orangefs_inode_getattr (file->f_mapping->host,0 ,1 , +STATX_SIZE ); +if (rc == -ESTALE ) + rc = -EIO ; +if (rc) { +gossip_err ("%s: orangefs_inode_getattr failed, " +"rc:%d:.\n" , __func__, rc); +return rc; + } +return filemap_fault (vmf); +} + +const struct vm_operations_struct orangefs_file_vm_ops = { + .fault = orangefs_fault, + .map_pages = filemap_map_pages, + .page_mkwrite = filemap_page_mkwrite, +}; +/* * Memory map a region of a file. */
@@ -538,12 +560,16 @@ 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 ; -/* Use readonly mmap since we cannot support writable maps. */ -return generic_file_readonly_mmap (file, vma); +file_accessed (file); + vma->vm_ops = &orangefs_file_vm_ops; +return 0 ; }#define mapping_nrpages (idata) ((idata)->nrpages)
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 6/24 orangefs: implement xattr cache
In reply to Martin BrandenburgThis 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 | 10 +++++ fs/orangefs/super.c | 9 ++++ fs/orangefs/xattr.c | 97 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+)
fs/orangefs/inode.c +1 -0
@@ -363,6 +363,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 +10 -0
@@ -195,6 +195,8 @@ struct orangefs_inode_s {unsigned long getattr_time;u32 getattr_mask; + +DECLARE_HASHTABLE (xattr_cache,4 ); };/* per superblock private orangefs info */
@@ -219,6 +221,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 +9 -0
@@ -127,6 +127,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 +97 -0
157 lines not on this page · raw message
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 7/24 orangefs: simpler installation documentation
In reply to Martin BrandenburgUnless one is working on the userspace code, there's no need to compile OrangeFS. The package works just fine.
Also document the process to run xfstests against OrangeFS.
--- Documentation/filesystems/orangefs.txt | 84 ++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 28 deletions(-)
Documentation/filesystems/orangefs.txt +56 -28
@@ -42,48 +42,76 @@ Orangefs versions prior to 2.9.3 would not be compatible with the upstream version of the kernel client. -BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER -==================================================== +RUNNING ORANGEFS ON A SINGLE SERVER +=================================== -You can omit --prefix if you don't care that things are sprinkled around in -/usr/local. As of version 2.9.6, Orangefs uses Berkeley DB by default, we -will probably be changing the default to lmdb soon. +OrangeFS is usually run in large installations with multiple servers and +clients, but a complete filesystem can be run on a single machine for +development and testing. -./configure --prefix=/opt/ofs --with-db-backend=lmdb +On Fedora, install orangefs and orangefs-server. -make +dnf -y install orangefs orangefs-server -make install +There is an example server configuration file in +/etc/orangefs/orangefs.conf. Change localhost to your hostname. -Create an orangefs config file: -/opt/ofs/bin/pvfs2-genconfig /etc/pvfs2.conf +To generate a filesystem to run xfstests against, see below. - for "Enter hostnames", use the hostname, don't let it default to - localhost. +There is an example client configuration file in /etc/pvfs2tab. It is a +single line. Uncomment it and change the hostname if necessary. This +controls clients which use libpvfs2. This does not control the +pvfs2-client-core. -create a pvfs2tab file in /etc: -cat /etc/pvfs2tab -tcp://myhostname:3334/orangefs /mymountpoint pvfs2 defaults,noauto 0 0 +Create the filesystem. -create the mount point you specified in the tab file if needed: -mkdir /mymountpoint +pvfs2-server -f /etc/orangefs/orangefs.conf -bootstrap the server: -/opt/ofs/sbin/pvfs2-server /etc/pvfs2.conf -f +Start the server. -start the server: -/opt/osf/sbin/pvfs2-server /etc/pvfs2.conf +systemctl start orangefs-server -Now the server is running. At this point you might like to -prove things are working with: +Test the server. -/opt/osf/bin/pvfs2-ls /mymountpoint +pvfs2-ping -m /pvfsmnt -If stuff seems to be working, turn on the client core: -/opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core +Start the client. The module must be compiled in or loaded before this +point. -Mount your filesystem. -mount -t pvfs2 tcp://myhostname:3334/orangefs /mymountpoint +systemctl start orangefs-client + +Mount the filesystem. + +mount -t pvfs2 tcp://localhost:3334/orangefs /pvfsmnt + + +RUNNING XFSTESTS +================ + +It is useful to use a scratch filesystem with xfstests. This can be +done with only one server. + +Make a second copy of the FileSystem section in the server configuration +file, which is /etc/orangefs/orangefs.conf. Change the Name to scratch. +Change the ID to something other than the ID of the first FileSystem +section (2 is usually a good choice). + +Then there are two FileSystem sections: orangefs and scratch. + +This change should be made before creating the filesystem. + +pvfs2-server -f /etc/orangefs/orangefs.conf + +To run xfstests, create /etc/xfsqa.config. + +TEST_DIR=/orangefs +TEST_DEV=tcp://localhost:3334/orangefs +SCRATCH_MNT=/scratch +SCRATCH_DEV=tcp://localhost:3334/scratch + +Then xfstests can be run + +./check -pvfs2 OPTIONS
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 8/24 orangefs: add tracepoint for service_operation
In reply to Martin BrandenburgThis is the first tracepoint for OrangeFS.
Remove op_name argument to service_operation. It is only used for debug messages, and just as useful information can be extracted from the op.
--- fs/orangefs/Makefile | 4 +++- fs/orangefs/dcache.c | 3 +-- fs/orangefs/dir.c | 3 +-- fs/orangefs/file.c | 10 ++-------- fs/orangefs/inode.c | 2 +- fs/orangefs/namei.c | 12 +++++------- fs/orangefs/orangefs-debugfs.c | 4 +--- fs/orangefs/orangefs-kernel.h | 4 +--- fs/orangefs/orangefs-sysfs.c | 11 ++--------- fs/orangefs/orangefs-trace.c | 3 +++ fs/orangefs/orangefs-trace.h | 41 +++++++++++++++++++++++++++++++++++++++++ fs/orangefs/orangefs-utils.c | 9 +++------ fs/orangefs/super.c | 12 ++++++------ fs/orangefs/waitqueue.c | 15 +++++++-------- fs/orangefs/xattr.c | 14 ++++---------- 15 files changed, 81 insertions(+), 66 deletions(-) create mode 100644 fs/orangefs/orangefs-trace.c create mode 100644 fs/orangefs/orangefs-trace.h
fs/orangefs/Makefile +3 -1
@@ -8,4 +8,6 @@ obj-$(CONFIG_ORANGEFS_FS) += orangefs.o orangefs-objs := acl.o file.o orangefs-cache.o orangefs-utils.o xattr.o \ dcache.o inode.o orangefs-sysfs.o orangefs-mod.o super.o \ devorangefs-req.o namei.o symlink.o dir.o orangefs-bufmap.o \ - orangefs-debugfs.o waitqueue.o + orangefs-debugfs.o waitqueue.o orangefs-trace.o + +CFLAGS_orangefs-trace.o += -I$(src)
fs/orangefs/dcache.c +1 -2
@@ -41,8 +41,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry) __LINE__, get_interruptible_flag(parent_inode)); - err =service_operation (new_op,"orangefs_lookup" , -get_interruptible_flag (parent_inode)); + err =service_operation (new_op,get_interruptible_flag (parent_inode));/* Positive dentry: reject if error or not the same inode. */ if (inode) {
fs/orangefs/dir.c +1 -2
@@ -85,8 +85,7 @@ static int do_readdir(struct orangefs_inode_s *oi, op->upcall.req.readdir.buf_index = bufi; - r =service_operation (op,"orangefs_readdir" , -get_interruptible_flag (dentry->d_inode)); + r =service_operation (op,get_interruptible_flag (dentry->d_inode));orangefs_readdir_index_put (bufi);
fs/orangefs/file.c +2 -8
@@ -30,8 +30,7 @@ static int flush_racache(struct inode *inode)return -ENOMEM ; new_op->upcall.req.ra_cache_flush.refn = orangefs_inode->refn; - ret =service_operation (new_op,"orangefs_flush_racache" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: got return value of %d\n" , __func__, ret);
@@ -110,11 +109,7 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod llu(new_op->tag));/* Stage 2: Service the I/O operation */ - ret =service_operation (new_op, - type ==ORANGEFS_IO_WRITE ? -"file_write" : -"file_read" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));/* * If service_operation() returns -EAGAIN #and# the operation was
@@ -627,7 +622,6 @@ static int orangefs_fsync(struct file *file, new_op->upcall.req.fsync.refn = orangefs_inode->refn; ret =service_operation (new_op, -"orangefs_fsync" ,get_interruptible_flag (file_inode (file))); gossip_debug(GOSSIP_FILE_DEBUG,
fs/orangefs/inode.c +1 -1
@@ -180,7 +180,7 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) new_op->upcall.req.truncate.refn = orangefs_inode->refn; new_op->upcall.req.truncate.size = (__s64 ) iattr->ia_size; - ret =service_operation (new_op, __func__, + ret =service_operation (new_op,get_interruptible_flag (inode));/*
fs/orangefs/namei.c +5 -7
@@ -42,7 +42,7 @@ static int orangefs_create(struct inode *dir,strncpy (new_op->upcall.req.create.d_name, dentry->d_name.name,ORANGEFS_NAME_MAX -1 ); - ret =service_operation (new_op, __func__,get_interruptible_flag (dir)); + ret =service_operation (new_op,get_interruptible_flag (dir)); gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n",
@@ -150,7 +150,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, &new_op->upcall.req.lookup.parent_refn.khandle, new_op->upcall.req.lookup.parent_refn.fs_id); - ret =service_operation (new_op, __func__,get_interruptible_flag (dir)); + ret =service_operation (new_op,get_interruptible_flag (dir)); gossip_debug(GOSSIP_NAME_DEBUG, "Lookup Got %pU, fsid %d (ret=%d)\n",
@@ -245,8 +245,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)strncpy (new_op->upcall.req.remove.d_name, dentry->d_name.name,ORANGEFS_NAME_MAX -1 ); - ret =service_operation (new_op,"orangefs_unlink" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode)); gossip_debug(GOSSIP_NAME_DEBUG, "%s: service_operation returned:%d:\n",
@@ -302,7 +301,7 @@ static int orangefs_symlink(struct inode *dir, ORANGEFS_NAME_MAX - 1);strncpy (new_op->upcall.req.sym.target, symname,ORANGEFS_NAME_MAX -1 ); - ret =service_operation (new_op, __func__,get_interruptible_flag (dir)); + ret =service_operation (new_op,get_interruptible_flag (dir)); gossip_debug(GOSSIP_NAME_DEBUG, "Symlink Got ORANGEFS handle %pU on fsid %d (ret=%d)\n",
@@ -373,7 +372,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t modestrncpy (new_op->upcall.req.mkdir.d_name, dentry->d_name.name,ORANGEFS_NAME_MAX -1 ); - ret =service_operation (new_op, __func__,get_interruptible_flag (dir)); + ret =service_operation (new_op,get_interruptible_flag (dir)); gossip_debug(GOSSIP_NAME_DEBUG, "Mkdir Got ORANGEFS handle %pU on fsid %d\n",
@@ -458,7 +457,6 @@ static int orangefs_rename(struct inode *old_dir, ORANGEFS_NAME_MAX - 1); ret =service_operation (new_op, -"orangefs_rename" ,get_interruptible_flag (old_dentry->d_inode)); gossip_debug(GOSSIP_NAME_DEBUG,
fs/orangefs/orangefs-debugfs.c +1 -3
@@ -512,9 +512,7 @@ static ssize_t orangefs_debug_write(struct file *file, c_mask.mask2);/* service_operation returns 0 on success... */ - rc =service_operation (new_op, -"orangefs_param" , -ORANGEFS_OP_INTERRUPTIBLE ); + rc =service_operation (new_op,ORANGEFS_OP_INTERRUPTIBLE );if (rc) gossip_debug(GOSSIP_DEBUGFS_DEBUG,
fs/orangefs/orangefs-kernel.h +1 -3
@@ -439,9 +439,7 @@ extern const struct dentry_operations orangefs_dentry_operations;#define ORANGEFS_OP_NO_MUTEX 8/* don't acquire request_mutex */ #define ORANGEFS_OP_ASYNC 16/* Queue it, but don't wait */ -int service_operation (struct orangefs_kernel_op_s *op, -const char *op_name, -int flags); +int service_operation (struct orangefs_kernel_op_s *,int );#define get_interruptible_flag (inode) \ ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
fs/orangefs/orangefs-sysfs.c +2 -9
@@ -303,7 +303,6 @@ static ssize_t sysfs_service_op_show(struct kobject *kobj, {struct orangefs_kernel_op_s *new_op =NULL ;int rc =0 ; -char *ser_op_type =NULL ;__u32 op_alloc_type; gossip_debug(GOSSIP_SYSFS_DEBUG,
@@ -461,17 +460,11 @@ static ssize_t sysfs_service_op_show(struct kobject *kobj, goto out; } - -if (strcmp (kobj->name,PC_KOBJ_ID )) - ser_op_type ="orangefs_param" ; -else - ser_op_type ="orangefs_perf_count" ; -/* * The service_operation will return an errno return code on * error, and zero on success. */ - rc =service_operation (new_op, ser_op_type,ORANGEFS_OP_INTERRUPTIBLE ); + rc =service_operation (new_op,ORANGEFS_OP_INTERRUPTIBLE ); out:if (!rc) {
@@ -792,7 +785,7 @@ static ssize_t sysfs_service_op_store(struct kobject *kobj,* The service_operation will return a errno return code on * error, and zero on success. */ - rc =service_operation (new_op,"orangefs_param" ,ORANGEFS_OP_INTERRUPTIBLE ); + rc =service_operation (new_op,ORANGEFS_OP_INTERRUPTIBLE );if (rc <0 ) { gossip_err("sysfs_service_op_store: service op returned:%d:\n",
fs/orangefs/orangefs-trace.c new file +3 -0
@@ -0,0 +1,3 @@ +#include "orangefs-kernel.h" +#define CREATE_TRACE_POINTS +#include "orangefs-trace.h"
fs/orangefs/orangefs-trace.h new file +41 -0
41 lines not on this page · raw message
fs/orangefs/orangefs-utils.c +3 -6
@@ -304,8 +304,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass, new_op->upcall.req.getattr.mask =ORANGEFS_ATTR_SYS_ALL_NOHINT & ~ORANGEFS_ATTR_SYS_SIZE ; - ret =service_operation (new_op, __func__, -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));if (ret !=0 ) goto out;
@@ -419,8 +418,7 @@ int orangefs_inode_check_changed(struct inode *inode) new_op->upcall.req.getattr.mask =ORANGEFS_ATTR_SYS_TYPE |ORANGEFS_ATTR_SYS_LNK_TARGET ; - ret =service_operation (new_op, __func__, -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));if (ret !=0 ) goto out;
@@ -451,8 +449,7 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr) &new_op->upcall.req.setattr.attributes, iattr);if (ret >=0 ) { - ret =service_operation (new_op, __func__, -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode)); gossip_debug(GOSSIP_UTILS_DEBUG, "orangefs_inode_setattr: returning %d\n",
fs/orangefs/super.c +6 -6
@@ -176,7 +176,7 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)if (ORANGEFS_SB (sb)->flags &ORANGEFS_OPT_INTR ) flags =ORANGEFS_OP_INTERRUPTIBLE ; - ret =service_operation (new_op,"orangefs_statfs" , flags); + ret =service_operation (new_op, flags);if (new_op->downcall.status <0 ) goto out_op_release;
@@ -258,7 +258,7 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)* request_mutex to prevent other operations from bypassing * this one */ - ret =service_operation (new_op,"orangefs_remount" , + ret =service_operation (new_op,ORANGEFS_OP_PRIORITY |ORANGEFS_OP_NO_MUTEX ); gossip_debug(GOSSIP_SUPER_DEBUG, "orangefs_remount: mount got return value of %d\n",
@@ -280,7 +280,7 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)if (!new_op)return -ENOMEM ; new_op->upcall.req.features.features =0 ; - ret =service_operation (new_op,"orangefs_features" , + ret =service_operation (new_op,ORANGEFS_OP_PRIORITY |ORANGEFS_OP_NO_MUTEX );if (!ret) orangefs_features =
@@ -392,7 +392,7 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname) op->upcall.req.fs_umount.fs_id = fs_id;strncpy (op->upcall.req.fs_umount.orangefs_config_server, devname,ORANGEFS_MAX_SERVER_ADDR_LEN -1 ); - r =service_operation (op,"orangefs_fs_umount" ,0 ); + r =service_operation (op,0 );/* Not much to do about an error here. */ if (r)gossip_err ("orangefs_unmount: service_operation %d\n" , r);
@@ -492,7 +492,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,"Attempting ORANGEFS Mount via host %s\n" , new_op->upcall.req.fs_mount.orangefs_config_server); - ret =service_operation (new_op,"orangefs_mount" ,0 ); + ret =service_operation (new_op,0 );gossip_debug (GOSSIP_SUPER_DEBUG ,"orangefs_mount: mount got return value of %d\n" , ret);if (ret)
@@ -553,7 +553,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,if (!new_op)return ERR_PTR (-ENOMEM ); new_op->upcall.req.features.features =0 ; - ret =service_operation (new_op,"orangefs_features" ,0 ); + ret =service_operation (new_op,0 ); orangefs_features = new_op->downcall.resp.features.features;op_release (new_op); }else {
fs/orangefs/waitqueue.c +7 -8
@@ -15,6 +15,7 @@#include "orangefs-kernel.h" #include "orangefs-bufmap.h" +#include "orangefs-trace.h" static int wait_for_matching_downcall (struct orangefs_kernel_op_s *,long ,bool );static void orangefs_clean_up_interrupted_operation (struct orangefs_kernel_op_s *);
@@ -57,9 +58,7 @@ void purge_waiting_ops(void)* * Returns contents of op->downcall.status for convenience */ -int service_operation (struct orangefs_kernel_op_s *op, -const char *op_name, -int flags) +int service_operation (struct orangefs_kernel_op_s *op,int flags) {long timeout =MAX_SCHEDULE_TIMEOUT ;int ret =0 ;
@@ -74,10 +73,11 @@ int service_operation(struct orangefs_kernel_op_s *op,gossip_debug (GOSSIP_WAIT_DEBUG ,"%s: %s op:%p: process:%s: pid:%d:\n" , __func__, - op_name, +get_opname_string (op), op, current->comm, current->pid); +trace_orangefs_service_operation (op, flags);/* * If ORANGEFS_OP_NO_MUTEX was set in flags, we need to avoid
@@ -159,8 +159,7 @@ int service_operation(struct orangefs_kernel_op_s *op,/* failed to get matching downcall */ if (ret == -ETIMEDOUT ) {gossip_err ("%s: %s -- wait timed out; aborting attempt.\n" , - __func__, - op_name); + __func__,get_opname_string (op)); }/*
@@ -178,7 +177,7 @@ int service_operation(struct orangefs_kernel_op_s *op,"orangefs: tag %llu (%s)" " -- operation to be retried (%d attempt)\n" ,llu (op->tag), - op_name, +get_opname_string (op), op->attempts);/*
@@ -194,7 +193,7 @@ int service_operation(struct orangefs_kernel_op_s *op,gossip_debug (GOSSIP_WAIT_DEBUG ,"%s: %s returning: %d for %p.\n" , __func__, - op_name, +get_opname_string (op), ret, op);return ret;
fs/orangefs/xattr.c +4 -10
@@ -158,8 +158,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,*/ new_op->upcall.req.getxattr.key_sz =strlen (name) +1 ; - ret =service_operation (new_op,"orangefs_inode_getxattr" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));if (ret !=0 ) {if (ret == -ENOENT ) { ret = -ENODATA ;
@@ -265,9 +264,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name, (char *)new_op->upcall.req.removexattr.key, (int)new_op->upcall.req.removexattr.key_sz); - ret =service_operation (new_op, -"orangefs_inode_removexattr" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));if (ret == -ENOENT ) {/* * Request to replace a non-existent attribute is an error.
@@ -363,9 +360,7 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name, (int )new_op->upcall.req.setxattr.keyval.key_sz, size); - ret =service_operation (new_op, -"orangefs_inode_setxattr" , -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode)); gossip_debug(GOSSIP_XATTR_DEBUG, "orangefs_inode_setxattr: returning %d\n",
@@ -427,8 +422,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size) new_op->upcall.req.listxattr.token = token; new_op->upcall.req.listxattr.requested_count = (size ==0 ) ?0 :ORANGEFS_MAX_XATTR_LISTLEN ; - ret =service_operation (new_op, __func__, -get_interruptible_flag (inode)); + ret =service_operation (new_op,get_interruptible_flag (inode));if (ret !=0 ) goto done;
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 9/24 orangefs: tracepoints for orangefs_devreq_{read,write_iter,poll}
In reply to Martin Brandenburg--- fs/orangefs/devorangefs-req.c | 14 ++++++++++-- fs/orangefs/orangefs-trace.h | 50 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-)
fs/orangefs/devorangefs-req.c +12 -2
@@ -11,6 +11,7 @@#include "orangefs-kernel.h" #include "orangefs-bufmap.h" #include "orangefs-debugfs.h" +#include "orangefs-trace.h" #include <linux/debugfs.h> #include <linux/slab.h>
@@ -180,8 +181,10 @@ static ssize_t orangefs_devreq_read(struct file *file, }/* Check for an empty list before locking. */ -if (list_empty (&orangefs_request_list)) +if (list_empty (&orangefs_request_list)) { +trace_orangefs_devreq_read (0 ,1 ,NULL );return -EAGAIN ; + } restart: cur_op =NULL ;
@@ -250,6 +253,7 @@ static ssize_t orangefs_devreq_read(struct file *file,*/ if (!cur_op) {spin_unlock (&orangefs_request_list_lock); +trace_orangefs_devreq_read (0 ,0 ,NULL );return -EAGAIN ; }
@@ -314,6 +318,7 @@ static ssize_t orangefs_devreq_read(struct file *file,spin_unlock (&cur_op->lock);spin_unlock (&orangefs_htable_ops_in_progress_lock); +trace_orangefs_devreq_read (1 ,0 , cur_op);/* The client only asks to read one size buffer. */ return MAX_DEV_REQ_UPSIZE ; error:
@@ -340,6 +345,7 @@ static ssize_t orangefs_devreq_read(struct file *file,complete (&cur_op->waitq); }spin_unlock (&orangefs_request_list_lock); +trace_orangefs_devreq_read (0 ,0 , cur_op);return -EFAULT ; }
@@ -474,6 +480,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, } wakeup: +trace_orangefs_devreq_write_iter (op);/* * Return to vfs waitqueue, and back to service_operation * through wait_for_matching_downcall.
@@ -781,11 +788,14 @@ static __poll_t orangefs_devreq_poll(struct file *file, struct poll_table_struct *poll_table) {__poll_t poll_revent_mask =0 ; +int empty;poll_wait (file, &orangefs_request_list_waitq, poll_table); -if (!list_empty (&orangefs_request_list)) + empty =list_empty (&orangefs_request_list); +if (!empty) poll_revent_mask |=EPOLLIN ; +trace_orangefs_devreq_poll (empty);return poll_revent_mask; }
fs/orangefs/orangefs-trace.h +50 -0
56 lines not on this page · raw message
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 10/24 orangefs: do not invalidate attributes on inode create
In reply to Martin BrandenburgWhen 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
@@ -448,12 +448,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
@@ -77,8 +77,6 @@ static int orangefs_create(struct inode *dir,d_instantiate (dentry, inode);unlock_new_inode (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",
@@ -333,8 +331,6 @@ static int orangefs_symlink(struct inode *dir,d_instantiate (dentry, inode);unlock_new_inode (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",
@@ -403,8 +399,6 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t moded_instantiate (dentry, inode);unlock_new_inode (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.16.2
Martin Brandenburg
reviewerPATCH 11/24 orangefs: simply orangefs_inode_getattr interface
In reply to Martin BrandenburgNo 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 | 12 ++++++------ fs/orangefs/inode.c | 11 ++++++----- fs/orangefs/orangefs-kernel.h | 7 ++++--- fs/orangefs/orangefs-utils.c | 31 ++++++++++--------------------- 4 files changed, 26 insertions(+), 35 deletions(-)
fs/orangefs/file.c +6 -6
@@ -418,8 +418,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) {
@@ -526,8 +526,8 @@ static int orangefs_fault(struct vm_fault *vmf) {struct file *file = vmf->vma->vm_file;int rc; - 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) {
@@ -652,8 +652,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
@@ -161,7 +161,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) {
@@ -255,7 +255,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);
@@ -282,7 +283,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;
@@ -398,7 +399,7 @@ struct inode *orangefs_iget(struct super_block *sb, struct orangefs_object_krefif (!inode || !(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);
@@ -443,7 +444,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
@@ -194,7 +194,6 @@ struct orangefs_inode_s {sector_t last_failed_block_index_read;unsigned long getattr_time; -u32 getattr_mask;DECLARE_HASHTABLE (xattr_cache,4 ); };
@@ -398,8 +397,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. */
@@ -268,8 +269,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;
@@ -279,16 +279,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)
@@ -298,7 +291,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 =
@@ -308,7 +301,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);
@@ -324,7 +317,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; rounded_up_size =
@@ -340,7 +333,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 ; orangefs_inode->blksize =i_blocksize (inode);spin_lock (&inode->i_lock);
@@ -350,7 +343,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); orangefs_inode->blksize =i_blocksize (inode);
@@ -392,10 +385,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.16.2
Martin Brandenburg
reviewerPATCH 12/24 orangefs: update attributes rather than relying on server
In reply to Martin BrandenburgThis 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
@@ -321,14 +321,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
@@ -425,6 +425,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)
@@ -434,7 +435,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.16.2
Martin Brandenburg
reviewerPATCH 13/24 orangefs: hold i_lock during inode_getattr
In reply to Martin BrandenburgThis 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
@@ -252,8 +252,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,struct orangefs_inode_s *orangefs_inode =NULL ;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
@@ -276,12 +276,17 @@ int orangefs_inode_getattr(struct inode *inode, int flags)loff_t inode_size, rounded_up_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)
@@ -301,13 +306,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; } }
@@ -325,20 +340,16 @@ int orangefs_inode_getattr(struct inode *inode, int flags) inode->i_size = inode_size; orangefs_inode->blksize = new_op->downcall.resp.getattr.attributes.blksize; -spin_lock (&inode->i_lock); inode->i_bytes = inode_size; inode->i_blocks = (unsigned long )(rounded_up_size /512 ); -spin_unlock (&inode->i_lock); }break ;case S_IFDIR :if (flags) { inode->i_size =PAGE_SIZE ; orangefs_inode->blksize =i_blocksize (inode); -spin_lock (&inode->i_lock);inode_set_bytes (inode, inode->i_size); -spin_unlock (&inode->i_lock); }set_nlink (inode,1 );break ;
@@ -352,7 +363,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; }
@@ -362,7 +373,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->
@@ -386,6 +397,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.16.2
Martin Brandenburg
reviewerPATCH 14/24 orangefs: set up and use backing_dev_info
In reply to Martin Brandenburg--- fs/orangefs/super.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
fs/orangefs/super.c +14 -7
@@ -404,15 +404,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;
@@ -435,6 +431,10 @@ static int orangefs_fill_sb(struct super_block *sb, sb->s_blocksize_bits =orangefs_bufmap_shift_query (); 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,
@@ -513,6 +513,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.16.2
Martin Brandenburg
reviewerPATCH 15/24 orangefs: let setattr write to cached inode
In reply to Martin BrandenburgThis 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 | 10 +++------- fs/orangefs/super.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-)
fs/orangefs/inode.c +3 -7
@@ -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, "orangefs_setattr: called on %pd\n",
@@ -227,15 +227,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 , -"orangefs_setattr: inode_setattr returned %d\n" , - 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 ,"orangefs_setattr: returning %d\n" , ret);return ret;
fs/orangefs/super.c +16 -0
@@ -150,6 +150,21 @@ static void orangefs_destroy_inode(struct inode *inode)call_rcu (&inode->i_rcu, orangefs_i_callback); } +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'
@@ -307,6 +322,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.16.2
Martin Brandenburg
reviewerPATCH 16/24 orangefs: reorganize setattr functions to track attribute changes
In reply to Martin BrandenburgOrangeFS 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 | 36 ++++++-------- fs/orangefs/orangefs-kernel.h | 8 ++- fs/orangefs/orangefs-utils.c | 110 +++++++++++++++++------------------------- fs/orangefs/super.c | 11 +---- 6 files changed, 130 insertions(+), 115 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;
@@ -181,7 +181,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 +62 -14
116 lines not on this page · raw message
fs/orangefs/namei.c +16 -20
@@ -83,11 +83,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: gossip_debug(GOSSIP_NAME_DEBUG,
@@ -255,11 +254,11 @@ 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); + ret =0 ; }return ret; }
@@ -337,11 +336,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:return ret;
@@ -409,11 +407,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:return ret; }
@@ -435,11 +432,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
@@ -194,6 +194,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 ); };
@@ -346,7 +349,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);
@@ -404,7 +408,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 +43 -67
178 lines not on this page · raw message
fs/orangefs/super.c +1 -10
@@ -152,17 +152,8 @@ static void orangefs_destroy_inode(struct inode *inode)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.16.2
Martin Brandenburg
reviewerPATCH 17/24 orangefs: remove orangefs_readpages
In reply to Martin BrandenburgIt'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
@@ -14,7 +14,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;
@@ -59,42 +59,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 = list_entry(pages->prev, struct page, lru); -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)
@@ -140,7 +104,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.16.2
Martin Brandenburg
reviewerPATCH 18/24 orangefs: service ops done for writeback are not killable
In reply to Martin Brandenburg--- fs/orangefs/orangefs-kernel.h | 1 + fs/orangefs/orangefs-utils.c | 6 ++++-- fs/orangefs/waitqueue.c | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-)
fs/orangefs/orangefs-kernel.h +1 -0
@@ -443,6 +443,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 32int service_operation (struct orangefs_kernel_op_s *,int );
fs/orangefs/orangefs-utils.c +4 -2
@@ -270,7 +270,8 @@ int orangefs_inode_getattr(struct inode *inode, int flags) new_op->upcall.req.getattr.mask =ORANGEFS_ATTR_SYS_ALL_NOHINT & ~ORANGEFS_ATTR_SYS_SIZE ; - ret =service_operation (new_op,get_interruptible_flag (inode)); + ret =service_operation (new_op, +get_interruptible_flag (inode));if (ret !=0 ) goto out;
@@ -429,7 +430,8 @@ int orangefs_inode_setattr(struct inode *inode) orangefs_inode->attr_valid =0 ;spin_unlock (&inode->i_lock); - ret =service_operation (new_op,get_interruptible_flag (inode)); + ret =service_operation (new_op, +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 +11 -9
@@ -17,7 +17,7 @@#include "orangefs-bufmap.h" #include "orangefs-trace.h" -static int wait_for_matching_downcall (struct orangefs_kernel_op_s *,long ,bool ); +static int wait_for_matching_downcall (struct orangefs_kernel_op_s *,long ,int );static void orangefs_clean_up_interrupted_operation (struct orangefs_kernel_op_s *);/*
@@ -138,9 +138,7 @@ int service_operation(struct orangefs_kernel_op_s *op, int flags)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__,
@@ -311,10 +309,12 @@ static void* Returns with op->lock taken. */ static int wait_for_matching_downcall (struct orangefs_kernel_op_s *op, -long timeout, -bool interruptible) +long timeout,int flags) {long n; +int writeback = flags &ORANGEFS_OP_WRITEBACK , + interruptible = flags &ORANGEFS_OP_INTERRUPTIBLE ; +/* * There's a "schedule_timeout" inside of these wait
@@ -322,10 +322,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.16.2
Martin Brandenburg
reviewerPATCH 19/24 orangefs: migrate to generic_file_read_iter
In reply to Martin BrandenburgRemove 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 | 68 +++++-------------------------------------- fs/orangefs/inode.c | 63 +++++++++++++++------------------------ fs/orangefs/orangefs-kernel.h | 13 +++++---- 3 files changed, 38 insertions(+), 106 deletions(-)
fs/orangefs/file.c +7 -61
@@ -42,7 +42,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) {
@@ -234,7 +234,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;
@@ -335,67 +335,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 ; - -BUG_ON (iocb->private); - -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)
@@ -406,6 +350,8 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iteBUG_ON (iocb->private); +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
@@ -370,11 +370,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 */
@@ -385,6 +380,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.16.2
Martin Brandenburg
reviewerPATCH 20/24 orangefs: implement writepage
In reply to Martin BrandenburgNow 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 | 77 +++++++++----------------------------------- fs/orangefs/inode.c | 59 +++++++++++++++++++++++++++++---- fs/orangefs/orangefs-utils.c | 12 +++++-- 3 files changed, 78 insertions(+), 70 deletions(-)
fs/orangefs/file.c +15 -62
@@ -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. */
@@ -342,65 +343,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; - -BUG_ON (iocb->private); - -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); }/*
@@ -495,9 +442,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 ;
@@ -537,8 +481,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 ; }
@@ -556,6 +498,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) +return ret; + new_op =op_alloc (ORANGEFS_VFS_OP_FSYNC );if (!new_op)return -ENOMEM ;
@@ -636,6 +583,11 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl)return rc; } +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,
@@ -645,6 +597,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 +53 -6
82 lines not on this page · raw message
fs/orangefs/orangefs-utils.c +10 -2
@@ -245,12 +245,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 again; } +if (inode->i_state &I_DIRTY_PAGES ) { +spin_unlock (&inode->i_lock); +return 0 ; + }spin_unlock (&inode->i_lock);return 0 ; }
@@ -279,12 +283,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 ) { +spin_unlock (&inode->i_lock); +return 0 ; + }gossip_debug (GOSSIP_UTILS_DEBUG ,"%s: in cache or dirty\n" , __func__); ret =0 ;
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 21/24 orangefs: skip inode writeout if nothing to write
In reply to Martin BrandenburgWould 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
@@ -436,6 +436,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,
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 22/24 orangefs: write range tracking
In reply to Martin BrandenburgThis is necessary to ensure the uid/gid responsible for the write is communicated with the server. Only one uid/gid may have outstanding changes at a time. If another uid/gid writes while there are outstanding changes, the changes must be written out before the new data is put into the page.
--- fs/orangefs/file.c | 12 ++- fs/orangefs/inode.c | 243 +++++++++++++++++++++++++++++++++++++----- fs/orangefs/orangefs-kernel.h | 12 ++- 3 files changed, 237 insertions(+), 30 deletions(-)
fs/orangefs/file.c +8 -4
@@ -44,8 +44,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_request *wr) {struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode);struct orangefs_khandle *handle = &orangefs_inode->refn.khandle;
@@ -101,6 +101,10 @@ ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, __func__, (long)ret); goto out; } +if (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,
@@ -286,7 +290,7 @@ ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file, (int)*offset); ret =wait_for_direct_io (type, inode, offset, iter, - each_count,0 ); + each_count,0 ,NULL ); gossip_debug(GOSSIP_FILE_DEBUG, "%s(%pU): return from wait_for_io:%d\n", __func__,
@@ -428,7 +432,7 @@ static int orangefs_fault(struct vm_fault *vmf)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 +218 -25
308 lines not on this page · raw message
fs/orangefs/orangefs-kernel.h +11 -1
@@ -179,6 +179,14 @@ static inline void set_op_state_purged(struct orangefs_kernel_op_s *op) } } +struct orangefs_write_request { +loff_t pos; +unsigned len; +kuid_t uid; +kgid_t gid; +int mwrite; +}; +/* per inode private orangefs info */ struct orangefs_inode_s {struct orangefs_object_kref refn;
@@ -343,6 +351,8 @@ void fsid_key_table_finalize(void);/* * defined in inode.c */ +int orangefs_page_mkwrite (struct vm_fault *); + struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, int mode,
@@ -384,7 +394,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_request *);ssize_t do_readv_writev (enum ORANGEFS_io_type ,struct file *,loff_t *,struct iov_iter *);
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 23/24 orangefs: tracepoints for readpage and writeback
In reply to Martin Brandenburgtrace_orangefs_writepage and trace_orangefs_radpage are self explanatory.
trace_orangefs_early_writeback will be used to determine the cost of the inability to cache multiple writes from different uids or noncontiguous writes within a page.
--- fs/orangefs/inode.c | 11 +++++++++- fs/orangefs/orangefs-trace.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-)
fs/orangefs/inode.c +10 -1
@@ -13,6 +13,7 @@#include <linux/bvec.h> #include "orangefs-kernel.h" #include "orangefs-bufmap.h" +#include "orangefs-trace.h" static int orangefs_writepage_locked (struct page *page,struct writeback_control *wbc)
@@ -51,6 +52,8 @@ static int orangefs_writepage_locked(struct page *page, } +trace_orangefs_writepage (off, wlen, wr->mwrite); + bv.bv_page = page; bv.bv_len = wlen; bv.bv_offset =0 ;
@@ -82,20 +85,24 @@ static int do_writepage_if_necessary(struct page *page, loff_t pos, };int r;if (PagePrivate (page)) { +int noncontig; wr = (struct orangefs_write_request *)page_private (page);BUG_ON (!wr); + noncontig = pos + len < wr->pos || wr->pos + wr->len < pos;/* * If the new request is not contiguous with the last one or if * the uid or gid is different, the page must be written out * before continuing. */ -if (pos + len < wr->pos || wr->pos + wr->len < pos || +if (noncontig || !uid_eq (current_fsuid (), wr->uid) || !gid_eq (current_fsgid (), wr->gid)) { wbc.range_start =page_file_offset (page); wbc.range_end = wbc.range_start +PAGE_SIZE -1 ;wait_on_page_writeback (page);if (clear_page_dirty_for_io (page)) { +trace_orangefs_early_writeback (noncontig ? +1 :2 ); r =orangefs_writepage_locked (page, &wbc);if (r)return r;
@@ -205,6 +212,7 @@ static int orangefs_readpage(struct file *file, struct page *page)loff_t off; off =page_offset (page); +trace_orangefs_readpage (off,PAGE_SIZE ); bv.bv_page = page; bv.bv_len =PAGE_SIZE ; bv.bv_offset =0 ;
@@ -278,6 +286,7 @@ static void orangefs_invalidatepage(struct page *page, wbc.range_end = wbc.range_start +PAGE_SIZE -1 ;wait_on_page_writeback (page);if (clear_page_dirty_for_io (page)) { +trace_orangefs_early_writeback (0 ); r =orangefs_writepage_locked (page, &wbc);if (r)return ;
fs/orangefs/orangefs-trace.h +50 -0
62 lines not on this page · raw message
Signature · 1 line
2.16.2
Martin Brandenburg
reviewerPATCH 24/24 orangefs: tracepoints for getattr, setattr, and write_inode
In reply to Martin Brandenburgtrace_orangefs_early_setattr will be used to determine the cost of early attribute writes.
Otherwise self explanatory.
--- fs/orangefs/inode.c | 5 +++ fs/orangefs/orangefs-trace.h | 100 +++++++++++++++++++++++++++++++++++++++++++ fs/orangefs/orangefs-utils.c | 6 ++- 3 files changed, 110 insertions(+), 1 deletion(-)
fs/orangefs/inode.c +5 -0
@@ -438,6 +438,8 @@ int __orangefs_setattr(struct inode *inode, struct iattr *iattr)ORANGEFS_I (inode)->attr_valid = iattr->ia_valid; }else {spin_unlock (&inode->i_lock); +trace_orangefs_early_setattr (inode, +ORANGEFS_I (inode)->attr_valid, iattr->ia_valid);write_inode_now (inode,1 ); goto again; }
@@ -446,6 +448,8 @@ int __orangefs_setattr(struct inode *inode, struct iattr *iattr)ORANGEFS_I (inode)->attr_uid =current_fsuid ();ORANGEFS_I (inode)->attr_gid =current_fsgid (); } +trace_orangefs_setattr (inode,ORANGEFS_I (inode)->attr_valid, + iattr->ia_valid);setattr_copy (inode, iattr);spin_unlock (&inode->i_lock);mark_inode_dirty (inode);
@@ -492,6 +496,7 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,gossip_debug (GOSSIP_INODE_DEBUG ,"orangefs_getattr: called on %pd mask %u\n" , path->dentry, request_mask); +trace_orangefs_getattr (inode, request_mask); ret =orangefs_inode_getattr (inode, request_mask &STATX_SIZE ?ORANGEFS_GETATTR_SIZE :0 );
fs/orangefs/orangefs-trace.h +100 -0
118 lines not on this page · raw message
fs/orangefs/orangefs-utils.c +5 -1
@@ -8,6 +8,7 @@#include <linux/kernel.h> #include "orangefs-kernel.h" #include "orangefs-bufmap.h" +#include "orangefs-trace.h" __s32 fsid_of_op (struct orangefs_kernel_op_s *op) {
@@ -423,7 +424,7 @@ int orangefs_inode_setattr(struct inode *inode) {struct orangefs_inode_s *orangefs_inode =ORANGEFS_I (inode);struct orangefs_kernel_op_s *new_op; -int ret; +int attr_valid, ret; new_op =op_alloc (ORANGEFS_VFS_OP_SETATTR );if (!new_op)
@@ -435,6 +436,7 @@ int orangefs_inode_setattr(struct inode *inode) new_op->upcall.req.setattr.refn = orangefs_inode->refn;copy_attributes_from_inode (inode, &new_op->upcall.req.setattr.attributes); + attr_valid = orangefs_inode->attr_valid; orangefs_inode->attr_valid =0 ;if (!new_op->upcall.req.setattr.attributes.mask) {spin_unlock (&inode->i_lock);
@@ -443,6 +445,8 @@ int orangefs_inode_setattr(struct inode *inode) }spin_unlock (&inode->i_lock); +trace_orangefs_write_inode (inode, attr_valid); + ret =service_operation (new_op,get_interruptible_flag (inode) |ORANGEFS_OP_WRITEBACK ); gossip_debug(GOSSIP_UTILS_DEBUG,
Signature · 1 line
2.16.2