ocfs2: nowait aio support
PATCH 23/119 ocfs2: nowait aio support
From: Gang He <[email protected]>
Subject: ocfs2: nowait aio support
Return EAGAIN if any of the following checks fail for direct I/O:
- Cannot get the related locks immediately
- Blocks are not allocated at the write location, it will trigger block allocation and block IO operations.
[[email protected]: v4]
[[email protected]: v2]
Signed-off-by Gang He <[email protected]>
Reviewed-by Alex Chen <[email protected]>
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Junxiao Bi <[email protected]>
Cc Joseph Qi <[email protected]>
Cc Changwei Ge <[email protected]>
Cc Jun Piao <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
fs/ocfs2/dir.c | 2 fs/ocfs2/dlmglue.c | 20 +++++-- fs/ocfs2/dlmglue.h | 2 fs/ocfs2/file.c | 101 ++++++++++++++++++++++++++++++--------- fs/ocfs2/mmap.c | 2 fs/ocfs2/ocfs2_trace.h | 10 ++- 6 files changed, 104 insertions(+), 33 deletions(-)
fs/ocfs2/dir.c renamed from fs/ocfs2/dir.c~ocfs2-nowait-aio-support +1 -1
@@ -1958,7 +1958,7 @@ int ocfs2_readdir(struct file *file, strtrace_ocfs2_readdir ((unsigned long long )OCFS2_I (inode)->ip_blkno); - error =ocfs2_inode_lock_atime (inode, file->f_path.mnt, &lock_level); + error =ocfs2_inode_lock_atime (inode, file->f_path.mnt, &lock_level,1 );if (lock_level && error >=0 ) {/* We release EX lock which used to update atime * and get PR lock again to reduce contention
fs/ocfs2/dlmglue.c renamed from fs/ocfs2/dlmglue.c~ocfs2-nowait-aio-support +15 -5
@@ -2546,13 +2546,18 @@ int ocfs2_inode_lock_with_page(struct inint ocfs2_inode_lock_atime (struct inode *inode,struct vfsmount *vfsmnt, -int *level) +int *level,int wait) {int ret; - ret =ocfs2_inode_lock (inode,NULL ,0 ); +if (wait) + ret =ocfs2_inode_lock (inode,NULL ,0 ); +else + ret =ocfs2_try_inode_lock (inode,NULL ,0 ); +if (ret <0 ) { -mlog_errno (ret); +if (ret != -EAGAIN ) +mlog_errno (ret);return ret; }
@@ -2564,9 +2569,14 @@ int ocfs2_inode_lock_atime(struct inodestruct buffer_head *bh =NULL ;ocfs2_inode_unlock (inode,0 ); - ret =ocfs2_inode_lock (inode, &bh,1 ); +if (wait) + ret =ocfs2_inode_lock (inode, &bh,1 ); +else + ret =ocfs2_try_inode_lock (inode, &bh,1 ); +if (ret <0 ) { -mlog_errno (ret); +if (ret != -EAGAIN ) +mlog_errno (ret);return ret; } *level =1 ;
fs/ocfs2/dlmglue.h renamed from fs/ocfs2/dlmglue.h~ocfs2-nowait-aio-support +1 -1
@@ -146,7 +146,7 @@ int ocfs2_try_open_lock(struct inode *invoid ocfs2_open_unlock (struct inode *inode);int ocfs2_inode_lock_atime (struct inode *inode,struct vfsmount *vfsmnt, -int *level); +int *level,int wait); int ocfs2_inode_lock_full_nested(struct inode *inode, struct buffer_head **ret_bh, int ex,
fs/ocfs2/file.c renamed from fs/ocfs2/file.c~ocfs2-nowait-aio-support +80 -21
199 lines not on this page · raw message
fs/ocfs2/mmap.c renamed from fs/ocfs2/mmap.c~ocfs2-nowait-aio-support +1 -1
@@ -184,7 +184,7 @@ int ocfs2_mmap(struct file *file, structint ret =0 , lock_level =0 ; ret =ocfs2_inode_lock_atime (file_inode (file), - file->f_path.mnt, &lock_level); + file->f_path.mnt, &lock_level,1 );if (ret <0 ) {mlog_errno (ret); goto out;
fs/ocfs2/ocfs2_trace.h renamed from fs/ocfs2/ocfs2_trace.h~ocfs2-nowait-aio-support +6 -4
@@ -1449,20 +1449,22 @@ DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_remTRACE_EVENT (ocfs2_prepare_inode_for_write, TP_PROTO(unsigned long long ino, unsigned long long saved_pos, - unsigned long count), -TP_ARGS (ino, saved_pos, count), + unsigned long count, int wait), +TP_ARGS (ino, saved_pos, count, wait),TP_STRUCT__entry ( __field(unsigned long long, ino) __field(unsigned long long, saved_pos) __field(unsigned long, count) +__field (int, wait) ),TP_fast_assign ( __entry->ino = ino; __entry->saved_pos = saved_pos; __entry->count = count; + __entry->wait = wait; ), -TP_printk ("%llu %llu %lu" , __entry->ino, - __entry->saved_pos, __entry->count) +TP_printk ("%llu %llu %lu %d" , __entry->ino, + __entry->saved_pos, __entry->count, __entry->wait) );DEFINE_OCFS2_INT_EVENT (generic_file_aio_read_ret);
_