* [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode)
@ 2014-10-12 20:42 Eric Biggers
2014-10-12 20:42 ` [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd() Eric Biggers
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Eric Biggers @ 2014-10-12 20:42 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, Eric Biggers
anon_inode_inode is allocated by anon_inode_init(), which is fs_initcall
and will panic if it couldn't be allocated.
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
fs/anon_inodes.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 80ef38c..1faff09 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -75,9 +75,6 @@ struct file *anon_inode_getfile(const char *name,
struct path path;
struct file *file;
- if (IS_ERR(anon_inode_inode))
- return ERR_PTR(-ENODEV);
-
if (fops->owner && !try_module_get(fops->owner))
return ERR_PTR(-ENOENT);
--
2.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
2014-10-12 20:42 [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode) Eric Biggers
@ 2014-10-12 20:42 ` Eric Biggers
2014-10-12 21:07 ` Al Viro
2014-10-12 20:42 ` [PATCH 3/5] fs/anon_inodes.c: Mark anon_inode_inode __read_mostly Eric Biggers
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Eric Biggers @ 2014-10-12 20:42 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, Eric Biggers
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
fs/anon_inodes.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 1faff09..268153a 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -136,26 +136,20 @@ EXPORT_SYMBOL_GPL(anon_inode_getfile);
int anon_inode_getfd(const char *name, const struct file_operations *fops,
void *priv, int flags)
{
- int error, fd;
+ int fd;
struct file *file;
- error = get_unused_fd_flags(flags);
- if (error < 0)
- return error;
- fd = error;
+ fd = get_unused_fd_flags(flags);
+ if (fd < 0)
+ return fd;
file = anon_inode_getfile(name, fops, priv, flags);
if (IS_ERR(file)) {
- error = PTR_ERR(file);
- goto err_put_unused_fd;
+ put_unused_fd(fd);
+ return PTR_ERR(file);
}
fd_install(fd, file);
-
return fd;
-
-err_put_unused_fd:
- put_unused_fd(fd);
- return error;
}
EXPORT_SYMBOL_GPL(anon_inode_getfd);
--
2.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] fs/anon_inodes.c: Mark anon_inode_inode __read_mostly
2014-10-12 20:42 [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode) Eric Biggers
2014-10-12 20:42 ` [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd() Eric Biggers
@ 2014-10-12 20:42 ` Eric Biggers
2014-10-12 20:42 ` [PATCH 4/5] fs/anon_inodes.c: Remove unneeded #includes Eric Biggers
2014-10-12 20:42 ` [PATCH 5/5] fs/anon_inodes.c: Remove incorrect information in comment Eric Biggers
3 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2014-10-12 20:42 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, Eric Biggers
At least, for consistency with anon_inode_mnt.
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
fs/anon_inodes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 268153a..444a705 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -23,7 +23,7 @@
#include <asm/uaccess.h>
static struct vfsmount *anon_inode_mnt __read_mostly;
-static struct inode *anon_inode_inode;
+static struct inode *anon_inode_inode __read_mostly;
/*
* anon_inodefs_dname() is called from d_path().
--
2.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] fs/anon_inodes.c: Remove unneeded #includes
2014-10-12 20:42 [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode) Eric Biggers
2014-10-12 20:42 ` [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd() Eric Biggers
2014-10-12 20:42 ` [PATCH 3/5] fs/anon_inodes.c: Mark anon_inode_inode __read_mostly Eric Biggers
@ 2014-10-12 20:42 ` Eric Biggers
2014-10-12 20:42 ` [PATCH 5/5] fs/anon_inodes.c: Remove incorrect information in comment Eric Biggers
3 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2014-10-12 20:42 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, Eric Biggers
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
fs/anon_inodes.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 444a705..bbfa038 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -8,10 +8,7 @@
*
*/
-#include <linux/cred.h>
#include <linux/file.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/mount.h>
@@ -20,8 +17,6 @@
#include <linux/magic.h>
#include <linux/anon_inodes.h>
-#include <asm/uaccess.h>
-
static struct vfsmount *anon_inode_mnt __read_mostly;
static struct inode *anon_inode_inode __read_mostly;
--
2.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] fs/anon_inodes.c: Remove incorrect information in comment
2014-10-12 20:42 [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode) Eric Biggers
` (2 preceding siblings ...)
2014-10-12 20:42 ` [PATCH 4/5] fs/anon_inodes.c: Remove unneeded #includes Eric Biggers
@ 2014-10-12 20:42 ` Eric Biggers
3 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2014-10-12 20:42 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel, Eric Biggers
Dentries for the anonymous inode are *not* named based on the inode
sequence number.
Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
fs/anon_inodes.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index bbfa038..ee81409 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -73,10 +73,7 @@ struct file *anon_inode_getfile(const char *name,
if (fops->owner && !try_module_get(fops->owner))
return ERR_PTR(-ENOENT);
- /*
- * Link the inode to a directory entry by creating a unique name
- * using the inode sequence number.
- */
+ /* Create a dentry for the new file. */
file = ERR_PTR(-ENOMEM);
this.name = name;
this.len = strlen(name);
--
2.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
2014-10-12 20:42 ` [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd() Eric Biggers
@ 2014-10-12 21:07 ` Al Viro
2014-10-12 22:51 ` Josh Triplett
0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2014-10-12 21:07 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-fsdevel, linux-kernel
On Sun, Oct 12, 2014 at 03:42:39PM -0500, Eric Biggers wrote:
> file = anon_inode_getfile(name, fops, priv, flags);
> if (IS_ERR(file)) {
> - error = PTR_ERR(file);
> - goto err_put_unused_fd;
> + put_unused_fd(fd);
> + return PTR_ERR(file);
> }
> fd_install(fd, file);
at least slap unlikely() on that if (IS_ERR(...))...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
2014-10-12 21:07 ` Al Viro
@ 2014-10-12 22:51 ` Josh Triplett
0 siblings, 0 replies; 7+ messages in thread
From: Josh Triplett @ 2014-10-12 22:51 UTC (permalink / raw)
To: Al Viro; +Cc: Eric Biggers, linux-fsdevel, linux-kernel
On Sun, Oct 12, 2014 at 10:07:13PM +0100, Al Viro wrote:
> On Sun, Oct 12, 2014 at 03:42:39PM -0500, Eric Biggers wrote:
> > file = anon_inode_getfile(name, fops, priv, flags);
> > if (IS_ERR(file)) {
> > - error = PTR_ERR(file);
> > - goto err_put_unused_fd;
> > + put_unused_fd(fd);
> > + return PTR_ERR(file);
> > }
> > fd_install(fd, file);
>
> at least slap unlikely() on that if (IS_ERR(...))...
That shouldn't be necessary, as far as I can tell; linux/err.h has:
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
...
static inline bool __must_check IS_ERR(__force const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}
So unless GCC fails to propagate expected-value handling through static
inline functions, you should never need to write unlikely(IS_ERR(...)).
- Josh Triplett
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-12 22:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-12 20:42 [PATCH 1/5] fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode) Eric Biggers
2014-10-12 20:42 ` [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd() Eric Biggers
2014-10-12 21:07 ` Al Viro
2014-10-12 22:51 ` Josh Triplett
2014-10-12 20:42 ` [PATCH 3/5] fs/anon_inodes.c: Mark anon_inode_inode __read_mostly Eric Biggers
2014-10-12 20:42 ` [PATCH 4/5] fs/anon_inodes.c: Remove unneeded #includes Eric Biggers
2014-10-12 20:42 ` [PATCH 5/5] fs/anon_inodes.c: Remove incorrect information in comment Eric Biggers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.