Skip to content

Commit bbd9d6f

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (107 commits) vfs: use ERR_CAST for err-ptr tossing in lookup_instantiate_filp isofs: Remove global fs lock jffs2: fix IN_DELETE_SELF on overwriting rename() killing a directory fix IN_DELETE_SELF on overwriting rename() on ramfs et.al. mm/truncate.c: fix build for CONFIG_BLOCK not enabled fs:update the NOTE of the file_operations structure Remove dead code in dget_parent() AFS: Fix silly characters in a comment switch d_add_ci() to d_splice_alias() in "found negative" case as well simplify gfs2_lookup() jfs_lookup(): don't bother with . or .. get rid of useless dget_parent() in btrfs rename() and link() get rid of useless dget_parent() in fs/btrfs/ioctl.c fs: push i_mutex and filemap_write_and_wait down into ->fsync() handlers drivers: fix up various ->llseek() implementations fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek Ext4: handle SEEK_HOLE/SEEK_DATA generically Btrfs: implement our own ->llseek fs: add SEEK_HOLE and SEEK_DATA flags reiserfs: make reiserfs default to barrier=flush ... Fix up trivial conflicts in fs/xfs/linux-2.6/xfs_super.c due to the new shrinker callout for the inode cache, that clashed with the xfs code to start the periodic workers later.
2 parents 8e20487 + 5a9a436 commit bbd9d6f

File tree

235 files changed

+2517
-1948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+2517
-1948
lines changed

Documentation/filesystems/Locking

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ata *);
5252
void (*put_link) (struct dentry *, struct nameidata *, void *);
5353
void (*truncate) (struct inode *);
5454
int (*permission) (struct inode *, int, unsigned int);
55-
int (*check_acl)(struct inode *, int, unsigned int);
55+
int (*check_acl)(struct inode *, int);
5656
int (*setattr) (struct dentry *, struct iattr *);
5757
int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *);
5858
int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -412,7 +412,7 @@ prototypes:
412412
int (*open) (struct inode *, struct file *);
413413
int (*flush) (struct file *);
414414
int (*release) (struct inode *, struct file *);
415-
int (*fsync) (struct file *, int datasync);
415+
int (*fsync) (struct file *, loff_t start, loff_t end, int datasync);
416416
int (*aio_fsync) (struct kiocb *, int datasync);
417417
int (*fasync) (int, struct file *, int);
418418
int (*lock) (struct file *, int, struct file_lock *);
@@ -438,9 +438,7 @@ prototypes:
438438

439439
locking rules:
440440
All may block except for ->setlease.
441-
No VFS locks held on entry except for ->fsync and ->setlease.
442-
443-
->fsync() has i_mutex on inode.
441+
No VFS locks held on entry except for ->setlease.
444442

445443
->setlease has the file_list_lock held and must not sleep.
446444

Documentation/filesystems/porting

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,33 @@ Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set,
398398
so the i_size should not change when hole punching, even when puching the end of
399399
a file off.
400400

401-
--
402-
[mandatory]
403-
404401
--
405402
[mandatory]
406403
->get_sb() is gone. Switch to use of ->mount(). Typically it's just
407404
a matter of switching from calling get_sb_... to mount_... and changing the
408405
function type. If you were doing it manually, just switch from setting ->mnt_root
409406
to some pointer to returning that pointer. On errors return ERR_PTR(...).
407+
408+
--
409+
[mandatory]
410+
->permission(), generic_permission() and ->check_acl() have lost flags
411+
argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
412+
generic_permission() has also lost the check_acl argument; if you want
413+
non-NULL to be used for that inode, put it into ->i_op->check_acl.
414+
415+
--
416+
[mandatory]
417+
If you implement your own ->llseek() you must handle SEEK_HOLE and
418+
SEEK_DATA. You can hanle this by returning -EINVAL, but it would be nicer to
419+
support it in some way. The generic handler assumes that the entire file is
420+
data and there is a virtual hole at the end of the file. So if the provided
421+
offset is less than i_size and SEEK_DATA is specified, return the same offset.
422+
If the above is true for the offset and you are given SEEK_HOLE, return the end
423+
of the file. If the offset is i_size or greater return -ENXIO in either case.
424+
425+
[mandatory]
426+
If you have your own ->fsync() you must make sure to call
427+
filemap_write_and_wait_range() so that all dirty pages are synced out properly.
428+
You must also keep in mind that ->fsync() is not called with i_mutex held
429+
anymore, so if you require i_mutex locking you must make sure to take it and
430+
release it yourself.

Documentation/filesystems/vfs.txt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ struct super_operations {
229229

230230
ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);
231231
ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
232+
int (*nr_cached_objects)(struct super_block *);
233+
void (*free_cached_objects)(struct super_block *, int);
232234
};
233235

234236
All methods are called without any locks being held, unless otherwise
@@ -301,6 +303,26 @@ or bottom half).
301303

302304
quota_write: called by the VFS to write to filesystem quota file.
303305

306+
nr_cached_objects: called by the sb cache shrinking function for the
307+
filesystem to return the number of freeable cached objects it contains.
308+
Optional.
309+
310+
free_cache_objects: called by the sb cache shrinking function for the
311+
filesystem to scan the number of objects indicated to try to free them.
312+
Optional, but any filesystem implementing this method needs to also
313+
implement ->nr_cached_objects for it to be called correctly.
314+
315+
We can't do anything with any errors that the filesystem might
316+
encountered, hence the void return type. This will never be called if
317+
the VM is trying to reclaim under GFP_NOFS conditions, hence this
318+
method does not need to handle that situation itself.
319+
320+
Implementations must include conditional reschedule calls inside any
321+
scanning loop that is done. This allows the VFS to determine
322+
appropriate scan batch sizes without having to worry about whether
323+
implementations will cause holdoff problems due to large scan batch
324+
sizes.
325+
304326
Whoever sets up the inode is responsible for filling in the "i_op" field. This
305327
is a pointer to a "struct inode_operations" which describes the methods that
306328
can be performed on individual inodes.
@@ -333,8 +355,8 @@ struct inode_operations {
333355
void * (*follow_link) (struct dentry *, struct nameidata *);
334356
void (*put_link) (struct dentry *, struct nameidata *, void *);
335357
void (*truncate) (struct inode *);
336-
int (*permission) (struct inode *, int, unsigned int);
337-
int (*check_acl)(struct inode *, int, unsigned int);
358+
int (*permission) (struct inode *, int);
359+
int (*check_acl)(struct inode *, int);
338360
int (*setattr) (struct dentry *, struct iattr *);
339361
int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
340362
int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -423,7 +445,7 @@ otherwise noted.
423445
permission: called by the VFS to check for access rights on a POSIX-like
424446
filesystem.
425447

426-
May be called in rcu-walk mode (flags & IPERM_FLAG_RCU). If in rcu-walk
448+
May be called in rcu-walk mode (mask & MAY_NOT_BLOCK). If in rcu-walk
427449
mode, the filesystem must check the permission without blocking or
428450
storing to the inode.
429451

@@ -755,7 +777,7 @@ struct file_operations {
755777
int (*open) (struct inode *, struct file *);
756778
int (*flush) (struct file *);
757779
int (*release) (struct inode *, struct file *);
758-
int (*fsync) (struct file *, int datasync);
780+
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
759781
int (*aio_fsync) (struct kiocb *, int datasync);
760782
int (*fasync) (int, struct file *, int);
761783
int (*lock) (struct file *, int, struct file_lock *);

arch/arm/mach-tegra/clock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ static const struct file_operations possible_parents_fops = {
585585

586586
static int clk_debugfs_register_one(struct clk *c)
587587
{
588-
struct dentry *d, *child, *child_tmp;
588+
struct dentry *d;
589589

590590
d = debugfs_create_dir(c->name, clk_debugfs_root);
591591
if (!d)
@@ -614,10 +614,7 @@ static int clk_debugfs_register_one(struct clk *c)
614614
return 0;
615615

616616
err_out:
617-
d = c->dent;
618-
list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
619-
debugfs_remove(child);
620-
debugfs_remove(c->dent);
617+
debugfs_remove_recursive(c->dent);
621618
return -ENOMEM;
622619
}
623620

arch/arm/mach-ux500/clock.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -635,16 +635,13 @@ static const struct file_operations set_rate_fops = {
635635
static struct dentry *clk_debugfs_register_dir(struct clk *c,
636636
struct dentry *p_dentry)
637637
{
638-
struct dentry *d, *clk_d, *child, *child_tmp;
639-
char s[255];
640-
char *p = s;
638+
struct dentry *d, *clk_d;
639+
const char *p = c->name;
641640

642-
if (c->name == NULL)
643-
p += sprintf(p, "BUG");
644-
else
645-
p += sprintf(p, "%s", c->name);
641+
if (!p)
642+
p = "BUG";
646643

647-
clk_d = debugfs_create_dir(s, p_dentry);
644+
clk_d = debugfs_create_dir(p, p_dentry);
648645
if (!clk_d)
649646
return NULL;
650647

@@ -666,24 +663,10 @@ static struct dentry *clk_debugfs_register_dir(struct clk *c,
666663
return clk_d;
667664

668665
err_out:
669-
d = clk_d;
670-
list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
671-
debugfs_remove(child);
672-
debugfs_remove(clk_d);
666+
debugfs_remove_recursive(clk_d);
673667
return NULL;
674668
}
675669

676-
static void clk_debugfs_remove_dir(struct dentry *cdentry)
677-
{
678-
struct dentry *d, *child, *child_tmp;
679-
680-
d = cdentry;
681-
list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
682-
debugfs_remove(child);
683-
debugfs_remove(cdentry);
684-
return ;
685-
}
686-
687670
static int clk_debugfs_register_one(struct clk *c)
688671
{
689672
struct clk *pa = c->parent_periph;
@@ -700,7 +683,7 @@ static int clk_debugfs_register_one(struct clk *c)
700683
c->dent_bus = clk_debugfs_register_dir(c,
701684
bpa->dent_bus ? bpa->dent_bus : bpa->dent);
702685
if ((!c->dent_bus) && (c->dent)) {
703-
clk_debugfs_remove_dir(c->dent);
686+
debugfs_remove_recursive(c->dent);
704687
c->dent = NULL;
705688
return -ENOMEM;
706689
}

arch/arm/plat-omap/clock.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,10 @@ static struct dentry *clk_debugfs_root;
480480
static int clk_debugfs_register_one(struct clk *c)
481481
{
482482
int err;
483-
struct dentry *d, *child, *child_tmp;
483+
struct dentry *d;
484484
struct clk *pa = c->parent;
485-
char s[255];
486-
char *p = s;
487485

488-
p += sprintf(p, "%s", c->name);
489-
d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root);
486+
d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);
490487
if (!d)
491488
return -ENOMEM;
492489
c->dent = d;
@@ -509,10 +506,7 @@ static int clk_debugfs_register_one(struct clk *c)
509506
return 0;
510507

511508
err_out:
512-
d = c->dent;
513-
list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
514-
debugfs_remove(child);
515-
debugfs_remove(c->dent);
509+
debugfs_remove_recursive(c->dent);
516510
return err;
517511
}
518512

arch/arm/plat-samsung/clock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static struct dentry *clk_debugfs_root;
458458
static int clk_debugfs_register_one(struct clk *c)
459459
{
460460
int err;
461-
struct dentry *d, *child, *child_tmp;
461+
struct dentry *d;
462462
struct clk *pa = c->parent;
463463
char s[255];
464464
char *p = s;
@@ -488,10 +488,7 @@ static int clk_debugfs_register_one(struct clk *c)
488488
return 0;
489489

490490
err_out:
491-
d = c->dent;
492-
list_for_each_entry_safe(child, child_tmp, &d->d_subdirs, d_u.d_child)
493-
debugfs_remove(child);
494-
debugfs_remove(c->dent);
491+
debugfs_remove_recursive(c->dent);
495492
return err;
496493
}
497494

arch/arm/plat-spear/clock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static struct dentry *clk_debugfs_root;
916916
static int clk_debugfs_register_one(struct clk *c)
917917
{
918918
int err;
919-
struct dentry *d, *child;
919+
struct dentry *d;
920920
struct clk *pa = c->pclk;
921921
char s[255];
922922
char *p = s;
@@ -951,10 +951,7 @@ static int clk_debugfs_register_one(struct clk *c)
951951
return 0;
952952

953953
err_out:
954-
d = c->dent;
955-
list_for_each_entry(child, &d->d_subdirs, d_u.d_child)
956-
debugfs_remove(child);
957-
debugfs_remove(c->dent);
954+
debugfs_remove_recursive(c->dent);
958955
return err;
959956
}
960957

arch/powerpc/platforms/cell/spufs/file.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,9 +1850,16 @@ static int spufs_mfc_flush(struct file *file, fl_owner_t id)
18501850
return ret;
18511851
}
18521852

1853-
static int spufs_mfc_fsync(struct file *file, int datasync)
1853+
static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int datasync)
18541854
{
1855-
return spufs_mfc_flush(file, NULL);
1855+
struct inode *inode = file->f_path.dentry->d_inode;
1856+
int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
1857+
if (!err) {
1858+
mutex_lock(&inode->i_mutex);
1859+
err = spufs_mfc_flush(file, NULL);
1860+
mutex_unlock(&inode->i_mutex);
1861+
}
1862+
return err;
18561863
}
18571864

18581865
static int spufs_mfc_fasync(int fd, struct file *file, int on)

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -611,49 +611,42 @@ static int spufs_create_gang(struct inode *inode,
611611

612612
static struct file_system_type spufs_type;
613613

614-
long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
615-
struct file *filp)
614+
long spufs_create(struct path *path, struct dentry *dentry,
615+
unsigned int flags, mode_t mode, struct file *filp)
616616
{
617-
struct dentry *dentry;
618617
int ret;
619618

620619
ret = -EINVAL;
621620
/* check if we are on spufs */
622-
if (nd->path.dentry->d_sb->s_type != &spufs_type)
621+
if (path->dentry->d_sb->s_type != &spufs_type)
623622
goto out;
624623

625624
/* don't accept undefined flags */
626625
if (flags & (~SPU_CREATE_FLAG_ALL))
627626
goto out;
628627

629628
/* only threads can be underneath a gang */
630-
if (nd->path.dentry != nd->path.dentry->d_sb->s_root) {
629+
if (path->dentry != path->dentry->d_sb->s_root) {
631630
if ((flags & SPU_CREATE_GANG) ||
632-
!SPUFS_I(nd->path.dentry->d_inode)->i_gang)
631+
!SPUFS_I(path->dentry->d_inode)->i_gang)
633632
goto out;
634633
}
635634

636-
dentry = lookup_create(nd, 1);
637-
ret = PTR_ERR(dentry);
638-
if (IS_ERR(dentry))
639-
goto out_dir;
640-
641635
mode &= ~current_umask();
642636

643637
if (flags & SPU_CREATE_GANG)
644-
ret = spufs_create_gang(nd->path.dentry->d_inode,
645-
dentry, nd->path.mnt, mode);
638+
ret = spufs_create_gang(path->dentry->d_inode,
639+
dentry, path->mnt, mode);
646640
else
647-
ret = spufs_create_context(nd->path.dentry->d_inode,
648-
dentry, nd->path.mnt, flags, mode,
641+
ret = spufs_create_context(path->dentry->d_inode,
642+
dentry, path->mnt, flags, mode,
649643
filp);
650644
if (ret >= 0)
651-
fsnotify_mkdir(nd->path.dentry->d_inode, dentry);
645+
fsnotify_mkdir(path->dentry->d_inode, dentry);
652646
return ret;
653647

654-
out_dir:
655-
mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
656648
out:
649+
mutex_unlock(&path->dentry->d_inode->i_mutex);
657650
return ret;
658651
}
659652

arch/powerpc/platforms/cell/spufs/spufs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ extern const struct spufs_tree_descr spufs_dir_debug_contents[];
248248
/* system call implementation */
249249
extern struct spufs_calls spufs_calls;
250250
long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status);
251-
long spufs_create(struct nameidata *nd, unsigned int flags,
251+
long spufs_create(struct path *nd, struct dentry *dentry, unsigned int flags,
252252
mode_t mode, struct file *filp);
253253
/* ELF coredump callbacks for writing SPU ELF notes */
254254
extern int spufs_coredump_extra_notes_size(void);

arch/powerpc/platforms/cell/spufs/syscalls.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,17 @@ static long do_spu_run(struct file *filp,
6262
static long do_spu_create(const char __user *pathname, unsigned int flags,
6363
mode_t mode, struct file *neighbor)
6464
{
65-
char *tmp;
65+
struct path path;
66+
struct dentry *dentry;
6667
int ret;
6768

68-
tmp = getname(pathname);
69-
ret = PTR_ERR(tmp);
70-
if (!IS_ERR(tmp)) {
71-
struct nameidata nd;
72-
73-
ret = kern_path_parent(tmp, &nd);
74-
if (!ret) {
75-
nd.flags |= LOOKUP_OPEN | LOOKUP_CREATE;
76-
ret = spufs_create(&nd, flags, mode, neighbor);
77-
path_put(&nd.path);
78-
}
79-
putname(tmp);
69+
dentry = user_path_create(AT_FDCWD, pathname, &path, 1);
70+
ret = PTR_ERR(dentry);
71+
if (!IS_ERR(dentry)) {
72+
ret = spufs_create(&path, dentry, flags, mode, neighbor);
73+
mutex_unlock(&path.dentry->d_inode->i_mutex);
74+
dput(dentry);
75+
path_put(&path);
8076
}
8177

8278
return ret;

0 commit comments

Comments
 (0)