FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 01-04-2008, 11:14 AM
Steven Whitehouse
 
Default Streamline open and remove directio flag

Hi,

The following patch streamlines the open syscall so that in the case of
O_LARGEFILE opens, its a no-op. We still have to check for the filesize
being greater than MAX_NON_LFS for non-O_LARGEFILE opens. This is
possible due to the removal of the directio flag. This flag is obsolete,
has never been used so it is safe to remove it.

Also, since many files are opened without ever using flock, the
allocation of a struct gfs2_file is deferred until the actual flock call
is made. Once allocated, it is not removed until the file is closed, but
this will save both memory and time when opening files which do not call
flock at all.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>


diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index c85f4fd..c0801c3 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -430,7 +430,6 @@ struct gfs2_tune {
unsigned int gt_quota_quantum; /* Secs between syncs to quota file */
unsigned int gt_atime_quantum; /* Min secs between atime updates */
unsigned int gt_new_files_jdata;
- unsigned int gt_new_files_directio;
unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */
unsigned int gt_stall_secs; /* Detects trouble! */
unsigned int gt_complain_secs;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 53bca99..37af7d9 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -779,13 +779,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) ||
gfs2_tune_get(sdp, gt_new_files_jdata))
di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
- if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO) ||
- gfs2_tune_get(sdp, gt_new_files_directio))
- di->di_flags |= cpu_to_be32(GFS2_DIF_DIRECTIO);
} else if (S_ISDIR(mode)) {
di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
- GFS2_DIF_INHERIT_DIRECTIO);
- di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
GFS2_DIF_INHERIT_JDATA);
}

diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 597f7ff..43dd169 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -133,7 +133,6 @@ static const u32 fsflags_to_gfs2[32] = {
[7] = GFS2_DIF_NOATIME,
[12] = GFS2_DIF_EXHASH,
[14] = GFS2_DIF_INHERIT_JDATA,
- [20] = GFS2_DIF_INHERIT_DIRECTIO,
};

static const u32 gfs2_to_fsflags[32] = {
@@ -142,7 +141,6 @@ static const u32 gfs2_to_fsflags[32] = {
[gfs2fl_AppendOnly] = FS_APPEND_FL,
[gfs2fl_NoAtime] = FS_NOATIME_FL,
[gfs2fl_ExHash] = FS_INDEX_FL,
- [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL,
[gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
};

@@ -163,8 +161,6 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
if (!S_ISDIR(inode->i_mode)) {
if (ip->i_di.di_flags & GFS2_DIF_JDATA)
fsflags |= FS_JOURNAL_DATA_FL;
- if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
- fsflags |= FS_DIRECTIO_FL;
}
if (put_user(fsflags, ptr))
error = -EFAULT;
@@ -194,13 +190,11 @@ void gfs2_set_inode_flags(struct inode *inode)

/* Flags that can be set by user space */
#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA|
- GFS2_DIF_DIRECTIO|
GFS2_DIF_IMMUTABLE|
GFS2_DIF_APPENDONLY|
GFS2_DIF_NOATIME|
GFS2_DIF_SYNC|
GFS2_DIF_SYSTEM|
- GFS2_DIF_INHERIT_DIRECTIO|
GFS2_DIF_INHERIT_JDATA)

/**
@@ -285,8 +279,6 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
if (!S_ISDIR(inode->i_mode)) {
if (gfsflags & GFS2_DIF_INHERIT_JDATA)
gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA);
- if (gfsflags & GFS2_DIF_INHERIT_DIRECTIO)
- gfsflags ^= (GFS2_DIF_DIRECTIO | GFS2_DIF_INHERIT_DIRECTIO);
return do_gfs2_set_flags(filp, gfsflags, ~0);
}
return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
@@ -463,45 +455,17 @@ static int gfs2_open(struct inode *inode, struct file *file)
{
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_holder i_gh;
- struct gfs2_file *fp;
- int error;
-
- fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL);
- if (!fp)
- return -ENOMEM;
-
- mutex_init(&fp->f_fl_mutex);
-
- gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
- file->private_data = fp;
+ int error = 0;

- if (S_ISREG(ip->i_inode.i_mode)) {
+ if (S_ISREG(ip->i_inode.i_mode) && !(file->f_flags & O_LARGEFILE)) {
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
&i_gh);
- if (error)
- goto fail;
-
- if (!(file->f_flags & O_LARGEFILE) &&
- ip->i_di.di_size > MAX_NON_LFS) {
+ if (!error && (ip->i_di.di_size > MAX_NON_LFS))
error = -EOVERFLOW;
- goto fail_gunlock;
- }
-
- /* Listen to the Direct I/O flag */
-
- if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
- file->f_flags |= O_DIRECT;

gfs2_glock_dq_uninit(&i_gh);
}

- return 0;
-
-fail_gunlock:
- gfs2_glock_dq_uninit(&i_gh);
-fail:
- file->private_data = NULL;
- kfree(fp);
return error;
}

@@ -515,17 +479,10 @@ fail:

static int gfs2_close(struct inode *inode, struct file *file)
{
- struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
- struct gfs2_file *fp;
+ struct gfs2_file *fp = file->private_data;

- fp = file->private_data;
file->private_data = NULL;
-
- if (gfs2_assert_warn(sdp, fp))
- return -EIO;
-
kfree(fp);
-
return 0;
}

@@ -631,13 +588,22 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
static int do_flock(struct file *file, int cmd, struct file_lock *fl)
{
struct gfs2_file *fp = file->private_data;
- struct gfs2_holder *fl_gh = &fp->f_fl_gh;
+ struct gfs2_holder *fl_gh;
struct gfs2_inode *ip = GFS2_I(file->f_path.dentry->d_inode);
struct gfs2_glock *gl;
unsigned int state;
int flags;
int error = 0;

+ if (fp == NULL) {
+ fp = kzalloc(sizeof(struct gfs2_file), GFP_KERNEL);
+ if (fp == NULL)
+ return -ENOMEM;
+ mutex_init(&fp->f_fl_mutex);
+ file->private_data = fp;
+ }
+
+ fl_gh = &fp->f_fl_gh;
state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE
| GL_FLOCK;
@@ -679,8 +645,11 @@ out:
static void do_unflock(struct file *file, struct file_lock *fl)
{
struct gfs2_file *fp = file->private_data;
- struct gfs2_holder *fl_gh = &fp->f_fl_gh;
+ struct gfs2_holder *fl_gh;

+ if (fp == NULL)
+ return;
+ fl_gh = &fp->f_fl_gh;
mutex_lock(&fp->f_fl_mutex);
flock_lock_file_wait(file, fl);
if (fl_gh->gh_gl)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index fa86038..cfaa165 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -63,7 +63,6 @@ void gfs2_tune_init(struct gfs2_tune *gt)
gt->gt_quota_quantum = 60;
gt->gt_atime_quantum = 3600;
gt->gt_new_files_jdata = 0;
- gt->gt_new_files_directio = 0;
gt->gt_max_readahead = 1 << 18;
gt->gt_stall_secs = 600;
gt->gt_complain_secs = 10;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 08bc548..f133c22 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -433,7 +433,6 @@ TUNE_ATTR(max_readahead, 0);
TUNE_ATTR(complain_secs, 0);
TUNE_ATTR(statfs_slow, 0);
TUNE_ATTR(new_files_jdata, 0);
-TUNE_ATTR(new_files_directio, 0);
TUNE_ATTR(quota_simul_sync, 1);
TUNE_ATTR(quota_cache_secs, 1);
TUNE_ATTR(stall_secs, 1);
@@ -460,7 +459,6 @@ static struct attribute *tune_attrs[] = {
&tune_attr_quotad_secs.attr,
&tune_attr_quota_scale.attr,
&tune_attr_new_files_jdata.attr,
- &tune_attr_new_files_directio.attr,
NULL,
};
 

Thread Tools




All times are GMT. The time now is 01:10 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org