Commit a55f2d86 authored by Martin Brandenburg's avatar Martin Brandenburg Committed by Mike Marshall

orangefs: stop setting atime on inode dirty

The previous code path was to mark the inode dirty, let
orangefs_inode_dirty set a flag in our private inode, then later during
inode release call orangefs_flush_inode which notices the flag and
writes the atime out.

The code path worked almost identically for mtime, ctime, and mode
except that those flags are set explicitly and not as side effects of
dirty.

Now orangefs_flush_inode is removed.  Marking an inode dirty does not
imply an atime update.  Any place where flags were set before is now
an explicit call to orangefs_inode_setattr.  Since OrangeFS does not
utilize inode writeback, the attribute change should be written out
immediately.

Fixes generic/120.

In namei.c, there are several places where the directory mtime and ctime
are set, but only the mtime is sent to the server.  These don't seem
right, but I've left them as is for now.
Signed-off-by: default avatarMartin Brandenburg <martin@omnibond.com>
Signed-off-by: default avatarMike Marshall <hubcap@omnibond.com>
parent 296200d3
...@@ -155,13 +155,11 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -155,13 +155,11 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
int orangefs_init_acl(struct inode *inode, struct inode *dir) int orangefs_init_acl(struct inode *inode, struct inode *dir)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
struct posix_acl *default_acl, *acl; struct posix_acl *default_acl, *acl;
umode_t mode = inode->i_mode; umode_t mode = inode->i_mode;
struct iattr iattr;
int error = 0; int error = 0;
ClearModeFlag(orangefs_inode);
error = posix_acl_create(dir, &mode, &default_acl, &acl); error = posix_acl_create(dir, &mode, &default_acl, &acl);
if (error) if (error)
return error; return error;
...@@ -180,9 +178,11 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir) ...@@ -180,9 +178,11 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
/* If mode of the inode was changed, then do a forcible ->setattr */ /* If mode of the inode was changed, then do a forcible ->setattr */
if (mode != inode->i_mode) { if (mode != inode->i_mode) {
SetModeFlag(orangefs_inode); memset(&iattr, 0, sizeof iattr);
inode->i_mode = mode; inode->i_mode = mode;
orangefs_flush_inode(inode); iattr.ia_mode = mode;
iattr.ia_valid |= ATTR_MODE;
orangefs_inode_setattr(inode, &iattr);
} }
return error; return error;
......
...@@ -386,7 +386,6 @@ static int orangefs_dir_release(struct inode *inode, struct file *file) ...@@ -386,7 +386,6 @@ static int orangefs_dir_release(struct inode *inode, struct file *file)
{ {
struct orangefs_dir *od = file->private_data; struct orangefs_dir *od = file->private_data;
struct orangefs_dir_part *part = od->part; struct orangefs_dir_part *part = od->part;
orangefs_flush_inode(inode);
while (part) { while (part) {
struct orangefs_dir_part *next = part->next; struct orangefs_dir_part *next = part->next;
vfree(part); vfree(part);
......
...@@ -383,9 +383,15 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file, ...@@ -383,9 +383,15 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file,
if (type == ORANGEFS_IO_READ) { if (type == ORANGEFS_IO_READ) {
file_accessed(file); file_accessed(file);
} else { } else {
SetMtimeFlag(orangefs_inode); file_update_time(file);
inode->i_mtime = current_time(inode); /*
mark_inode_dirty_sync(inode); * 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;
} }
} }
...@@ -615,8 +621,6 @@ static int orangefs_file_release(struct inode *inode, struct file *file) ...@@ -615,8 +621,6 @@ static int orangefs_file_release(struct inode *inode, struct file *file)
"orangefs_file_release: called on %pD\n", "orangefs_file_release: called on %pD\n",
file); file);
orangefs_flush_inode(inode);
/* /*
* remove all associated inode pages from the page cache and * remove all associated inode pages from the page cache and
* readahead cache (if any); this forces an expensive refresh of * readahead cache (if any); this forces an expensive refresh of
...@@ -666,8 +670,6 @@ static int orangefs_fsync(struct file *file, ...@@ -666,8 +670,6 @@ static int orangefs_fsync(struct file *file,
ret); ret);
op_release(new_op); op_release(new_op);
orangefs_flush_inode(file_inode(file));
return ret; return ret;
} }
......
...@@ -290,6 +290,22 @@ int orangefs_permission(struct inode *inode, int mask) ...@@ -290,6 +290,22 @@ int orangefs_permission(struct inode *inode, int mask)
return generic_permission(inode, mask); return generic_permission(inode, mask);
} }
int orangefs_update_time(struct inode *inode, struct timespec *time, int flags)
{
struct iattr iattr;
gossip_debug(GOSSIP_INODE_DEBUG, "orangefs_update_time: %pU\n",
get_khandle_from_ino(inode));
generic_update_time(inode, time, flags);
memset(&iattr, 0, sizeof iattr);
if (flags & S_ATIME)
iattr.ia_valid |= ATTR_ATIME;
if (flags & S_CTIME)
iattr.ia_valid |= ATTR_CTIME;
if (flags & S_MTIME)
iattr.ia_valid |= ATTR_MTIME;
return orangefs_inode_setattr(inode, &iattr);
}
/* ORANGEDS2 implementation of VFS inode operations for files */ /* ORANGEDS2 implementation of VFS inode operations for files */
const struct inode_operations orangefs_file_inode_operations = { const struct inode_operations orangefs_file_inode_operations = {
.get_acl = orangefs_get_acl, .get_acl = orangefs_get_acl,
...@@ -298,6 +314,7 @@ const struct inode_operations orangefs_file_inode_operations = { ...@@ -298,6 +314,7 @@ const struct inode_operations orangefs_file_inode_operations = {
.getattr = orangefs_getattr, .getattr = orangefs_getattr,
.listxattr = orangefs_listxattr, .listxattr = orangefs_listxattr,
.permission = orangefs_permission, .permission = orangefs_permission,
.update_time = orangefs_update_time,
}; };
static int orangefs_init_iops(struct inode *inode) static int orangefs_init_iops(struct inode *inode)
......
...@@ -23,6 +23,7 @@ static int orangefs_create(struct inode *dir, ...@@ -23,6 +23,7 @@ static int orangefs_create(struct inode *dir,
struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_inode_s *parent = ORANGEFS_I(dir);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
struct inode *inode; struct inode *inode;
struct iattr iattr;
int ret; int ret;
gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd\n", gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd\n",
...@@ -82,8 +83,10 @@ static int orangefs_create(struct inode *dir, ...@@ -82,8 +83,10 @@ static int orangefs_create(struct inode *dir,
__func__, __func__,
dentry); dentry);
SetMtimeFlag(parent);
dir->i_mtime = dir->i_ctime = current_time(dir); 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); mark_inode_dirty_sync(dir);
ret = 0; ret = 0;
out: out:
...@@ -221,6 +224,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -221,6 +224,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_inode_s *parent = ORANGEFS_I(dir);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
struct iattr iattr;
int ret; int ret;
gossip_debug(GOSSIP_NAME_DEBUG, gossip_debug(GOSSIP_NAME_DEBUG,
...@@ -253,8 +257,10 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -253,8 +257,10 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
if (!ret) { if (!ret) {
drop_nlink(inode); drop_nlink(inode);
SetMtimeFlag(parent);
dir->i_mtime = dir->i_ctime = current_time(dir); 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); mark_inode_dirty_sync(dir);
} }
return ret; return ret;
...@@ -267,6 +273,7 @@ static int orangefs_symlink(struct inode *dir, ...@@ -267,6 +273,7 @@ static int orangefs_symlink(struct inode *dir,
struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_inode_s *parent = ORANGEFS_I(dir);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
struct inode *inode; struct inode *inode;
struct iattr iattr;
int mode = 755; int mode = 755;
int ret; int ret;
...@@ -331,8 +338,10 @@ static int orangefs_symlink(struct inode *dir, ...@@ -331,8 +338,10 @@ static int orangefs_symlink(struct inode *dir,
get_khandle_from_ino(inode), get_khandle_from_ino(inode),
dentry); dentry);
SetMtimeFlag(parent);
dir->i_mtime = dir->i_ctime = current_time(dir); 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); mark_inode_dirty_sync(dir);
ret = 0; ret = 0;
out: out:
...@@ -345,6 +354,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode ...@@ -345,6 +354,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
struct orangefs_inode_s *parent = ORANGEFS_I(dir); struct orangefs_inode_s *parent = ORANGEFS_I(dir);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
struct inode *inode; struct inode *inode;
struct iattr iattr;
int ret; int ret;
new_op = op_alloc(ORANGEFS_VFS_OP_MKDIR); new_op = op_alloc(ORANGEFS_VFS_OP_MKDIR);
...@@ -400,8 +410,10 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode ...@@ -400,8 +410,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 * NOTE: we have no good way to keep nlink consistent for directories
* across clients; keep constant at 1. * across clients; keep constant at 1.
*/ */
SetMtimeFlag(parent);
dir->i_mtime = dir->i_ctime = current_time(dir); 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); mark_inode_dirty_sync(dir);
out: out:
op_release(new_op); op_release(new_op);
...@@ -470,4 +482,5 @@ const struct inode_operations orangefs_dir_inode_operations = { ...@@ -470,4 +482,5 @@ const struct inode_operations orangefs_dir_inode_operations = {
.getattr = orangefs_getattr, .getattr = orangefs_getattr,
.listxattr = orangefs_listxattr, .listxattr = orangefs_listxattr,
.permission = orangefs_permission, .permission = orangefs_permission,
.update_time = orangefs_update_time,
}; };
...@@ -209,37 +209,10 @@ struct orangefs_inode_s { ...@@ -209,37 +209,10 @@ struct orangefs_inode_s {
struct inode vfs_inode; struct inode vfs_inode;
sector_t last_failed_block_index_read; sector_t last_failed_block_index_read;
/*
* State of in-memory attributes not yet flushed to disk associated
* with this object
*/
unsigned long pinode_flags;
unsigned long getattr_time; unsigned long getattr_time;
u32 getattr_mask; u32 getattr_mask;
}; };
#define P_ATIME_FLAG 0
#define P_MTIME_FLAG 1
#define P_CTIME_FLAG 2
#define P_MODE_FLAG 3
#define ClearAtimeFlag(pinode) clear_bit(P_ATIME_FLAG, &(pinode)->pinode_flags)
#define SetAtimeFlag(pinode) set_bit(P_ATIME_FLAG, &(pinode)->pinode_flags)
#define AtimeFlag(pinode) test_bit(P_ATIME_FLAG, &(pinode)->pinode_flags)
#define ClearMtimeFlag(pinode) clear_bit(P_MTIME_FLAG, &(pinode)->pinode_flags)
#define SetMtimeFlag(pinode) set_bit(P_MTIME_FLAG, &(pinode)->pinode_flags)
#define MtimeFlag(pinode) test_bit(P_MTIME_FLAG, &(pinode)->pinode_flags)
#define ClearCtimeFlag(pinode) clear_bit(P_CTIME_FLAG, &(pinode)->pinode_flags)
#define SetCtimeFlag(pinode) set_bit(P_CTIME_FLAG, &(pinode)->pinode_flags)
#define CtimeFlag(pinode) test_bit(P_CTIME_FLAG, &(pinode)->pinode_flags)
#define ClearModeFlag(pinode) clear_bit(P_MODE_FLAG, &(pinode)->pinode_flags)
#define SetModeFlag(pinode) set_bit(P_MODE_FLAG, &(pinode)->pinode_flags)
#define ModeFlag(pinode) test_bit(P_MODE_FLAG, &(pinode)->pinode_flags)
/* per superblock private orangefs info */ /* per superblock private orangefs info */
struct orangefs_sb_info_s { struct orangefs_sb_info_s {
struct orangefs_khandle root_khandle; struct orangefs_khandle root_khandle;
...@@ -442,6 +415,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat, ...@@ -442,6 +415,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,
int orangefs_permission(struct inode *inode, int mask); int orangefs_permission(struct inode *inode, int mask);
int orangefs_update_time(struct inode *, struct timespec *, int);
/* /*
* defined in xattr.c * defined in xattr.c
*/ */
...@@ -484,8 +459,6 @@ bool __is_daemon_in_service(void); ...@@ -484,8 +459,6 @@ bool __is_daemon_in_service(void);
*/ */
__s32 fsid_of_op(struct orangefs_kernel_op_s *op); __s32 fsid_of_op(struct orangefs_kernel_op_s *op);
int orangefs_flush_inode(struct inode *inode);
ssize_t orangefs_inode_getxattr(struct inode *inode, ssize_t orangefs_inode_getxattr(struct inode *inode,
const char *name, const char *name,
void *buffer, void *buffer,
......
...@@ -438,89 +438,8 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr) ...@@ -438,89 +438,8 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr)
op_release(new_op); op_release(new_op);
/* if (ret == 0)
* successful setattr should clear the atime, mtime and
* ctime flags.
*/
if (ret == 0) {
ClearAtimeFlag(orangefs_inode);
ClearMtimeFlag(orangefs_inode);
ClearCtimeFlag(orangefs_inode);
ClearModeFlag(orangefs_inode);
orangefs_inode->getattr_time = jiffies - 1; orangefs_inode->getattr_time = jiffies - 1;
}
return ret;
}
int orangefs_flush_inode(struct inode *inode)
{
/*
* If it is a dirty inode, this function gets called.
* Gather all the information that needs to be setattr'ed
* Right now, this will only be used for mode, atime, mtime
* and/or ctime.
*/
struct iattr wbattr;
int ret;
int mtime_flag;
int ctime_flag;
int atime_flag;
int mode_flag;
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
memset(&wbattr, 0, sizeof(wbattr));
/*
* check inode flags up front, and clear them if they are set. This
* will prevent multiple processes from all trying to flush the same
* inode if they call close() simultaneously
*/
mtime_flag = MtimeFlag(orangefs_inode);
ClearMtimeFlag(orangefs_inode);
ctime_flag = CtimeFlag(orangefs_inode);
ClearCtimeFlag(orangefs_inode);
atime_flag = AtimeFlag(orangefs_inode);
ClearAtimeFlag(orangefs_inode);
mode_flag = ModeFlag(orangefs_inode);
ClearModeFlag(orangefs_inode);
/* -- Lazy atime,mtime and ctime update --
* Note: all times are dictated by server in the new scheme
* and not by the clients
*
* Also mode updates are being handled now..
*/
if (mtime_flag)
wbattr.ia_valid |= ATTR_MTIME;
if (ctime_flag)
wbattr.ia_valid |= ATTR_CTIME;
if (atime_flag)
wbattr.ia_valid |= ATTR_ATIME;
if (mode_flag) {
wbattr.ia_mode = inode->i_mode;
wbattr.ia_valid |= ATTR_MODE;
}
gossip_debug(GOSSIP_UTILS_DEBUG,
"*********** orangefs_flush_inode: %pU "
"(ia_valid %d)\n",
get_khandle_from_ino(inode),
wbattr.ia_valid);
if (wbattr.ia_valid == 0) {
gossip_debug(GOSSIP_UTILS_DEBUG,
"orangefs_flush_inode skipping setattr()\n");
return 0;
}
gossip_debug(GOSSIP_UTILS_DEBUG,
"orangefs_flush_inode (%pU) writing mode %o\n",
get_khandle_from_ino(inode),
inode->i_mode);
ret = orangefs_inode_setattr(inode, &wbattr);
return ret; return ret;
} }
......
...@@ -117,7 +117,6 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb) ...@@ -117,7 +117,6 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
orangefs_inode->refn.fs_id = ORANGEFS_FS_ID_NULL; orangefs_inode->refn.fs_id = ORANGEFS_FS_ID_NULL;
orangefs_inode->last_failed_block_index_read = 0; orangefs_inode->last_failed_block_index_read = 0;
memset(orangefs_inode->link_target, 0, sizeof(orangefs_inode->link_target)); memset(orangefs_inode->link_target, 0, sizeof(orangefs_inode->link_target));
orangefs_inode->pinode_flags = 0;
gossip_debug(GOSSIP_SUPER_DEBUG, gossip_debug(GOSSIP_SUPER_DEBUG,
"orangefs_alloc_inode: allocated %p\n", "orangefs_alloc_inode: allocated %p\n",
...@@ -297,21 +296,9 @@ void fsid_key_table_finalize(void) ...@@ -297,21 +296,9 @@ void fsid_key_table_finalize(void)
{ {
} }
/* Called whenever the VFS dirties the inode in response to atime updates */
static void orangefs_dirty_inode(struct inode *inode, int flags)
{
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
gossip_debug(GOSSIP_SUPER_DEBUG,
"orangefs_dirty_inode: %pU\n",
get_khandle_from_ino(inode));
SetAtimeFlag(orangefs_inode);
}
static const struct super_operations orangefs_s_ops = { static const struct super_operations orangefs_s_ops = {
.alloc_inode = orangefs_alloc_inode, .alloc_inode = orangefs_alloc_inode,
.destroy_inode = orangefs_destroy_inode, .destroy_inode = orangefs_destroy_inode,
.dirty_inode = orangefs_dirty_inode,
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.statfs = orangefs_statfs, .statfs = orangefs_statfs,
.remount_fs = orangefs_remount_fs, .remount_fs = orangefs_remount_fs,
......
...@@ -15,4 +15,5 @@ const struct inode_operations orangefs_symlink_inode_operations = { ...@@ -15,4 +15,5 @@ const struct inode_operations orangefs_symlink_inode_operations = {
.getattr = orangefs_getattr, .getattr = orangefs_getattr,
.listxattr = orangefs_listxattr, .listxattr = orangefs_listxattr,
.permission = orangefs_permission, .permission = orangefs_permission,
.update_time = orangefs_update_time,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment