Skip to content

Commit

Permalink
[PATCH] inotify: use fget_light
Browse files Browse the repository at this point in the history
As an optimization, use fget_light() and fput_light() where possible.

Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: John McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Robert Love authored and Linus Torvalds committed Jul 26, 2005
1 parent b680716 commit 33ea2f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions fs/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,10 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
struct inotify_device *dev;
struct nameidata nd;
struct file *filp;
int ret;
int ret, fput_needed;

filp = fget(fd);
if (!filp)
filp = fget_light(fd, &fput_needed);
if (unlikely(!filp))
return -EBADF;

ret = find_inode(path, &nd);
Expand Down Expand Up @@ -973,22 +973,22 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
up(&dev->sem);
up(&inode->inotify_sem);
fput_and_out:
fput(filp);
fput_light(filp, fput_needed);
return ret;
}

asmlinkage long sys_inotify_rm_watch(int fd, u32 wd)
{
struct file *filp;
struct inotify_device *dev;
int ret;
int ret, fput_needed;

filp = fget(fd);
if (!filp)
filp = fget_light(fd, &fput_needed);
if (unlikely(!filp))
return -EBADF;
dev = filp->private_data;
ret = inotify_ignore(dev, wd);
fput(filp);
fput_light(filp, fput_needed);

return ret;
}
Expand Down

0 comments on commit 33ea2f5

Please sign in to comment.