Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6:
  merge fchmod() and fchmodat() guts, kill ancient broken kludge
  xfs: fix misspelled S_IS...()
  xfs: get rid of open-coded S_ISREG(), etc.
  vfs: document locking requirements for d_move, __d_move and d_materialise_unique
  omfs: fix (mode & S_IFDIR) abuse
  btrfs: S_ISREG(mode) is not mode & S_IFREG...
  ima: fmode_t misspelled as mode_t...
  pci-label.c: size_t misspelled as mode_t
  jffs2: S_ISLNK(mode & S_IFMT) is pointless
  snd_msnd ->mode is fmode_t, not mode_t
  v9fs_iop_get_acl: get rid of unused variable
  vfs: dont chain pipe/anon/socket on superblock s_inodes list
  Documentation: Exporting: update description of d_splice_alias
  fs: add missing unlock in default_llseek()
  • Loading branch information
torvalds committed Jul 27, 2011
2 parents b0189cd + e57712e commit e371d46
Show file tree
Hide file tree
Showing 25 changed files with 133 additions and 120 deletions.
9 changes: 8 additions & 1 deletion Documentation/filesystems/nfs/Exporting
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ For a filesystem to be exportable it must:
1/ provide the filehandle fragment routines described below.
2/ make sure that d_splice_alias is used rather than d_add
when ->lookup finds an inode for a given parent and name.
Typically the ->lookup routine will end with a:

If inode is NULL, d_splice_alias(inode, dentry) is eqivalent to

d_add(dentry, inode), NULL

Similarly, d_splice_alias(ERR_PTR(err), dentry) = ERR_PTR(err)

Typically the ->lookup routine will simply end with a:

return d_splice_alias(inode, dentry);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/pci-label.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum smbios_attr_enum {
SMBIOS_ATTR_INSTANCE_SHOW,
};

static mode_t
static size_t
find_smbios_instance_string(struct pci_dev *pdev, char *buf,
enum smbios_attr_enum attribute)
{
Expand Down
2 changes: 1 addition & 1 deletion fs/anon_inodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ EXPORT_SYMBOL_GPL(anon_inode_getfd);
*/
static struct inode *anon_inode_mkinode(void)
{
struct inode *inode = new_inode(anon_inode_mnt->mnt_sb);
struct inode *inode = new_inode_pseudo(anon_inode_mnt->mnt_sb);

if (!inode)
return ERR_PTR(-ENOMEM);
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4467,7 +4467,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
inode->i_generation = BTRFS_I(inode)->generation;
btrfs_set_inode_space_info(root, inode);

if (mode & S_IFDIR)
if (S_ISDIR(mode))
owner = 0;
else
owner = 1;
Expand Down Expand Up @@ -4512,7 +4512,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,

btrfs_inherit_iflags(inode, dir);

if ((mode & S_IFREG)) {
if (S_ISREG(mode)) {
if (btrfs_test_opt(root, NODATASUM))
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
if (btrfs_test_opt(root, NODATACOW) ||
Expand Down
11 changes: 7 additions & 4 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2138,8 +2138,9 @@ static void dentry_unlock_parents_for_move(struct dentry *dentry,
* @target: new dentry
*
* Update the dcache to reflect the move of a file name. Negative
* dcache entries should not be moved in this way. Caller hold
* rename_lock.
* dcache entries should not be moved in this way. Caller must hold
* rename_lock, the i_mutex of the source and target directories,
* and the sb->s_vfs_rename_mutex if they differ. See lock_rename().
*/
static void __d_move(struct dentry * dentry, struct dentry * target)
{
Expand Down Expand Up @@ -2202,7 +2203,8 @@ static void __d_move(struct dentry * dentry, struct dentry * target)
* @target: new dentry
*
* Update the dcache to reflect the move of a file name. Negative
* dcache entries should not be moved in this way.
* dcache entries should not be moved in this way. See the locking
* requirements for __d_move.
*/
void d_move(struct dentry *dentry, struct dentry *target)
{
Expand Down Expand Up @@ -2320,7 +2322,8 @@ static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon)
* @inode: inode to bind to the dentry, to which aliases may be attached
*
* Introduces an dentry into the tree, substituting an extant disconnected
* root directory alias in its place if there is one
* root directory alias in its place if there is one. Caller must hold the
* i_mutex of the parent directory.
*/
struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
{
Expand Down
39 changes: 30 additions & 9 deletions fs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,11 @@ EXPORT_SYMBOL_GPL(inode_sb_list_add);

static inline void inode_sb_list_del(struct inode *inode)
{
spin_lock(&inode_sb_list_lock);
list_del_init(&inode->i_sb_list);
spin_unlock(&inode_sb_list_lock);
if (!list_empty(&inode->i_sb_list)) {
spin_lock(&inode_sb_list_lock);
list_del_init(&inode->i_sb_list);
spin_unlock(&inode_sb_list_lock);
}
}

static unsigned long hash(struct super_block *sb, unsigned long hashval)
Expand Down Expand Up @@ -795,6 +797,29 @@ unsigned int get_next_ino(void)
}
EXPORT_SYMBOL(get_next_ino);

/**
* new_inode_pseudo - obtain an inode
* @sb: superblock
*
* Allocates a new inode for given superblock.
* Inode wont be chained in superblock s_inodes list
* This means :
* - fs can't be unmount
* - quotas, fsnotify, writeback can't work
*/
struct inode *new_inode_pseudo(struct super_block *sb)
{
struct inode *inode = alloc_inode(sb);

if (inode) {
spin_lock(&inode->i_lock);
inode->i_state = 0;
spin_unlock(&inode->i_lock);
INIT_LIST_HEAD(&inode->i_sb_list);
}
return inode;
}

/**
* new_inode - obtain an inode
* @sb: superblock
Expand All @@ -813,13 +838,9 @@ struct inode *new_inode(struct super_block *sb)

spin_lock_prefetch(&inode_sb_list_lock);

inode = alloc_inode(sb);
if (inode) {
spin_lock(&inode->i_lock);
inode->i_state = 0;
spin_unlock(&inode->i_lock);
inode = new_inode_pseudo(sb);
if (inode)
inode_sb_list_add(inode);
}
return inode;
}
EXPORT_SYMBOL(new_inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
if (ret) {
jffs2_free_raw_inode(ri);
if (S_ISLNK(inode->i_mode & S_IFMT))
if (S_ISLNK(inode->i_mode))
kfree(mdata);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/omfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int omfs_make_empty(struct inode *inode, struct super_block *sb)

memset(bh->b_data, 0, sizeof(struct omfs_inode));

if (inode->i_mode & S_IFDIR) {
if (S_ISDIR(inode->i_mode)) {
memset(&bh->b_data[OMFS_DIR_START], 0xff,
sbi->s_sys_blocksize - OMFS_DIR_START);
} else
Expand Down
78 changes: 28 additions & 50 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,74 +446,52 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
return error;
}

SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode)
static int chmod_common(struct path *path, umode_t mode)
{
struct inode * inode;
struct dentry * dentry;
struct file * file;
int err = -EBADF;
struct inode *inode = path->dentry->d_inode;
struct iattr newattrs;
int error;

file = fget(fd);
if (!file)
goto out;

dentry = file->f_path.dentry;
inode = dentry->d_inode;

audit_inode(NULL, dentry);

err = mnt_want_write_file(file);
if (err)
goto out_putf;
error = mnt_want_write(path->mnt);
if (error)
return error;
mutex_lock(&inode->i_mutex);
err = security_path_chmod(dentry, file->f_vfsmnt, mode);
if (err)
error = security_path_chmod(path->dentry, path->mnt, mode);
if (error)
goto out_unlock;
if (mode == (mode_t) -1)
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
err = notify_change(dentry, &newattrs);
error = notify_change(path->dentry, &newattrs);
out_unlock:
mutex_unlock(&inode->i_mutex);
mnt_drop_write(file->f_path.mnt);
out_putf:
fput(file);
out:
mnt_drop_write(path->mnt);
return error;
}

SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode)
{
struct file * file;
int err = -EBADF;

file = fget(fd);
if (file) {
audit_inode(NULL, file->f_path.dentry);
err = chmod_common(&file->f_path, mode);
fput(file);
}
return err;
}

SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode)
{
struct path path;
struct inode *inode;
int error;
struct iattr newattrs;

error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
if (error)
goto out;
inode = path.dentry->d_inode;

error = mnt_want_write(path.mnt);
if (error)
goto dput_and_out;
mutex_lock(&inode->i_mutex);
error = security_path_chmod(path.dentry, path.mnt, mode);
if (error)
goto out_unlock;
if (mode == (mode_t) -1)
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
error = notify_change(path.dentry, &newattrs);
out_unlock:
mutex_unlock(&inode->i_mutex);
mnt_drop_write(path.mnt);
dput_and_out:
path_put(&path);
out:
if (!error) {
error = chmod_common(&path, mode);
path_put(&path);
}
return error;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ static const struct dentry_operations pipefs_dentry_operations = {

static struct inode * get_pipe_inode(void)
{
struct inode *inode = new_inode(pipe_mnt->mnt_sb);
struct inode *inode = new_inode_pseudo(pipe_mnt->mnt_sb);
struct pipe_inode_info *pipe;

if (!inode)
Expand Down
12 changes: 8 additions & 4 deletions fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,21 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
* long as offset isn't at the end of the file then the
* offset is data.
*/
if (offset >= inode->i_size)
return -ENXIO;
if (offset >= inode->i_size) {
retval = -ENXIO;
goto out;
}
break;
case SEEK_HOLE:
/*
* There is a virtual hole at the end of the file, so
* as long as offset isn't i_size or larger, return
* i_size.
*/
if (offset >= inode->i_size)
return -ENXIO;
if (offset >= inode->i_size) {
retval = -ENXIO;
goto out;
}
offset = inode->i_size;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ xfs_open_by_handle(
return PTR_ERR(filp);
}

if (inode->i_mode & S_IFREG) {
if (S_ISREG(inode->i_mode)) {
filp->f_flags |= O_NOATIME;
filp->f_mode |= FMODE_NOCMTIME;
}
Expand Down Expand Up @@ -850,14 +850,14 @@ xfs_set_diflags(
di_flags |= XFS_DIFLAG_NODEFRAG;
if (xflags & XFS_XFLAG_FILESTREAM)
di_flags |= XFS_DIFLAG_FILESTREAM;
if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
if (S_ISDIR(ip->i_d.di_mode)) {
if (xflags & XFS_XFLAG_RTINHERIT)
di_flags |= XFS_DIFLAG_RTINHERIT;
if (xflags & XFS_XFLAG_NOSYMLINKS)
di_flags |= XFS_DIFLAG_NOSYMLINKS;
if (xflags & XFS_XFLAG_EXTSZINHERIT)
di_flags |= XFS_DIFLAG_EXTSZINHERIT;
} else if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) {
} else if (S_ISREG(ip->i_d.di_mode)) {
if (xflags & XFS_XFLAG_REALTIME)
di_flags |= XFS_DIFLAG_REALTIME;
if (xflags & XFS_XFLAG_EXTSIZE)
Expand Down
7 changes: 3 additions & 4 deletions fs/xfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ xfs_bmap_add_attrfork_local(

if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
return 0;
if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
if (S_ISDIR(ip->i_d.di_mode)) {
mp = ip->i_mount;
memset(&dargs, 0, sizeof(dargs));
dargs.dp = ip;
Expand Down Expand Up @@ -3344,8 +3344,7 @@ xfs_bmap_local_to_extents(
* We don't want to deal with the case of keeping inode data inline yet.
* So sending the data fork of a regular inode is invalid.
*/
ASSERT(!((ip->i_d.di_mode & S_IFMT) == S_IFREG &&
whichfork == XFS_DATA_FORK));
ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK));
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);
flags = 0;
Expand Down Expand Up @@ -4052,7 +4051,7 @@ xfs_bmap_one_block(

#ifndef DEBUG
if (whichfork == XFS_DATA_FORK) {
return ((ip->i_d.di_mode & S_IFMT) == S_IFREG) ?
return S_ISREG(ip->i_d.di_mode) ?
(ip->i_size == ip->i_mount->m_sb.sb_blocksize) :
(ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
}
Expand Down
Loading

0 comments on commit e371d46

Please sign in to comment.