From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux FSdevel <linux-fsdevel@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
NFS maillist <nfs@lists.sourceforge.net>
Subject: [PATCH 1/4] Optimize NFS open() calls by means of 'intents'...
Date: Fri, 23 May 2003 14:45:01 +0200 [thread overview]
Message-ID: <16078.6093.339198.108592@charged.uio.no> (raw)
Minor cleanup of open() code. Put the original open flags, mode, etc. into
an 'opendata' structure that can be passed as an intent to lookup.
diff -u --recursive --new-file linux-2.5.69/fs/namei.c linux-2.5.69-01-open1/fs/namei.c
--- linux-2.5.69/fs/namei.c 2003-05-05 07:49:54.000000000 +0200
+++ linux-2.5.69-01-open1/fs/namei.c 2003-05-22 15:30:50.000000000 +0200
@@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/namei.h>
+#include <linux/open.h>
#include <linux/quotaops.h>
#include <linux/pagemap.h>
#include <linux/dnotify.h>
@@ -1204,19 +1205,18 @@
* for symlinks (where the permissions are checked later).
* SMP-safe
*/
-int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
+int open_namei(const char * pathname, struct opendata *opendata, struct nameidata *nd)
{
- int acc_mode, error = 0;
+ int flag = opendata->flag;
+ int error = 0;
struct dentry *dentry;
struct dentry *dir;
int count = 0;
- acc_mode = ACC_MODE(flag);
-
/* Allow the LSM permission hook to distinguish append
access from general write access. */
if (flag & O_APPEND)
- acc_mode |= MAY_APPEND;
+ opendata->acc_mode |= MAY_APPEND;
/*
* The simplest case - just a plain lookup.
@@ -1258,6 +1258,7 @@
/* Negative dentry, just create the file */
if (!dentry->d_inode) {
+ int mode = opendata->mode;
if (!IS_POSIXACL(dir->d_inode))
mode &= ~current->fs->umask;
error = vfs_create(dir->d_inode, dentry, mode);
@@ -1267,7 +1268,7 @@
if (error)
goto exit;
/* Don't check for write permission, don't truncate */
- acc_mode = 0;
+ opendata->acc_mode = 0;
flag &= ~O_TRUNC;
goto ok;
}
@@ -1299,7 +1300,7 @@
if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))
goto exit;
ok:
- error = may_open(nd, acc_mode, flag);
+ error = may_open(nd, opendata->acc_mode, flag);
if (error)
goto exit;
return 0;
diff -u --recursive --new-file linux-2.5.69/fs/open.c linux-2.5.69-01-open1/fs/open.c
--- linux-2.5.69/fs/open.c 2003-05-21 02:23:23.000000000 +0200
+++ linux-2.5.69-01-open1/fs/open.c 2003-05-22 14:25:57.000000000 +0200
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/namei.h>
+#include <linux/open.h>
#include <linux/backing-dev.h>
#include <linux/security.h>
#include <linux/mount.h>
@@ -602,6 +603,8 @@
return error;
}
+#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
+
/*
* Note that while the flag value (low two bits) for sys_open means:
* 00 - read-only
@@ -620,14 +623,19 @@
{
int namei_flags, error;
struct nameidata nd;
+ struct opendata opendata = {
+ .flag = flags,
+ .mode = mode,
+ };
namei_flags = flags;
if ((namei_flags+1) & O_ACCMODE)
namei_flags++;
if (namei_flags & O_TRUNC)
namei_flags |= 2;
+ opendata.acc_mode = ACC_MODE(namei_flags);
- error = open_namei(filename, namei_flags, mode, &nd);
+ error = open_namei(filename, &opendata, &nd);
if (!error)
return dentry_open(nd.dentry, nd.mnt, flags);
diff -u --recursive --new-file linux-2.5.69/include/linux/fs.h linux-2.5.69-01-open1/include/linux/fs.h
--- linux-2.5.69/include/linux/fs.h 2003-05-17 23:09:32.000000000 +0200
+++ linux-2.5.69-01-open1/include/linux/fs.h 2003-05-22 14:25:57.000000000 +0200
@@ -23,6 +23,7 @@
struct iovec;
struct nameidata;
+struct opendata;
struct pipe_inode_info;
struct poll_table_struct;
struct statfs;
@@ -1135,7 +1136,7 @@
}
extern int do_pipe(int *);
-extern int open_namei(const char *, int, int, struct nameidata *);
+extern int open_namei(const char *, struct opendata *, struct nameidata *);
extern int may_open(struct nameidata *, int, int);
extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
diff -u --recursive --new-file linux-2.5.69/include/linux/open.h linux-2.5.69-01-open1/include/linux/open.h
--- linux-2.5.69/include/linux/open.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.5.69-01-open1/include/linux/open.h 2003-05-22 14:25:57.000000000 +0200
@@ -0,0 +1,17 @@
+#ifndef _LINUX_OPEN_H
+#define _LINUX_OPEN_H
+
+struct opendata {
+ int flag;
+ int mode;
+ int acc_mode;
+
+#if 0
+ /* Private data to be added to the filp->private_data field */
+ void *private;
+ /* Callback for destroying private data in case of an error */
+ void (*destroy)(struct opendata *, void *);
+#endif
+};
+
+#endif
next reply other threads:[~2003-05-23 12:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-23 12:45 Trond Myklebust [this message]
2003-05-23 16:23 ` [PATCH 1/4] Optimize NFS open() calls by means of 'intents' Linus Torvalds
2003-05-23 17:59 ` viro
2003-05-23 18:32 ` Andreas Dilger
2003-06-30 14:36 Trond Myklebust
2003-06-30 15:14 ` Matthew Wilcox
2003-07-01 9:39 ` Trond Myklebust
2003-06-30 14:37 Trond Myklebust
2003-06-30 14:39 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16078.6093.339198.108592@charged.uio.no \
--to=trond.myklebust@fys.uio.no \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).