diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 17:49:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 17:49:16 -0400 |
commit | 34917f9713905a937816ebb7ee5f25bef7a6441c (patch) | |
tree | 2ae3ba2a12cfa5636b4bee65b5a750f786421520 /fs/gfs2/inode.c | |
parent | f7789dc0d476e597b0fba52871e777f97d8e3f6e (diff) | |
parent | 1b2ad41214c9bf6e8befa000f0522629194bf540 (diff) |
Merge tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw
Pull GFS2 updates from Steven Whitehouse:
"One of the main highlights this time, is not the patches themselves
but instead the widening contributor base. It is good to see that
interest is increasing in GFS2, and I'd like to thank all the
contributors to this patch set.
In addition to the usual set of bug fixes and clean ups, there are
patches to improve inode creation performance when xattrs are required
and some improvements to the transaction code which is intended to
help improve scalability after further changes in due course.
Journal extent mapping is also updated to make it more efficient and
again, this is a foundation for future work in this area.
The maximum number of ACLs has been increased to 300 (for a 4k block
size) which means that even with a few additional xattrs from selinux,
everything should fit within a single fs block.
There is also a patch to bring GFS2's own copy of the writepages code
up to the same level as the core VFS. Eventually we may be able to
merge some of this code, since it is fairly similar.
The other major change this time, is bringing consistency to the
printing of messages via fs_<level>, pr_<level> macros"
* tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw: (29 commits)
GFS2: Fix address space from page function
GFS2: Fix uninitialized VFS inode in gfs2_create_inode
GFS2: Fix return value in slot_get()
GFS2: inline function gfs2_set_mode
GFS2: Remove extraneous function gfs2_security_init
GFS2: Increase the max number of ACLs
GFS2: Re-add a call to log_flush_wait when flushing the journal
GFS2: Ensure workqueue is scheduled after noexp request
GFS2: check NULL return value in gfs2_ok_to_move
GFS2: Convert gfs2_lm_withdraw to use fs_err
GFS2: Use fs_<level> more often
GFS2: Use pr_<level> more consistently
GFS2: Move recovery variables to journal structure in memory
GFS2: global conversion to pr_foo()
GFS2: return -E2BIG if hit the maximum limits of ACLs
GFS2: Clean up journal extent mapping
GFS2: replace kmalloc - __vmalloc / memset 0
GFS2: Remove extra "if" in gfs2_log_flush()
fs: NULL dereference in posix_acl_to_xattr()
GFS2: Move log buffer accounting to transaction
...
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r-- | fs/gfs2/inode.c | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 5c524180c98e..28cc7bf6575a 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -376,12 +376,11 @@ static void munge_mode_uid_gid(const struct gfs2_inode *dip, | |||
376 | inode->i_gid = current_fsgid(); | 376 | inode->i_gid = current_fsgid(); |
377 | } | 377 | } |
378 | 378 | ||
379 | static int alloc_dinode(struct gfs2_inode *ip, u32 flags) | 379 | static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks) |
380 | { | 380 | { |
381 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 381 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
382 | struct gfs2_alloc_parms ap = { .target = RES_DINODE, .aflags = flags, }; | 382 | struct gfs2_alloc_parms ap = { .target = *dblocks, .aflags = flags, }; |
383 | int error; | 383 | int error; |
384 | int dblocks = 1; | ||
385 | 384 | ||
386 | error = gfs2_quota_lock_check(ip); | 385 | error = gfs2_quota_lock_check(ip); |
387 | if (error) | 386 | if (error) |
@@ -391,11 +390,11 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags) | |||
391 | if (error) | 390 | if (error) |
392 | goto out_quota; | 391 | goto out_quota; |
393 | 392 | ||
394 | error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 0); | 393 | error = gfs2_trans_begin(sdp, (*dblocks * RES_RG_BIT) + RES_STATFS + RES_QUOTA, 0); |
395 | if (error) | 394 | if (error) |
396 | goto out_ipreserv; | 395 | goto out_ipreserv; |
397 | 396 | ||
398 | error = gfs2_alloc_blocks(ip, &ip->i_no_addr, &dblocks, 1, &ip->i_generation); | 397 | error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation); |
399 | ip->i_no_formal_ino = ip->i_generation; | 398 | ip->i_no_formal_ino = ip->i_generation; |
400 | ip->i_inode.i_ino = ip->i_no_addr; | 399 | ip->i_inode.i_ino = ip->i_no_addr; |
401 | ip->i_goal = ip->i_no_addr; | 400 | ip->i_goal = ip->i_no_addr; |
@@ -428,6 +427,33 @@ static void gfs2_init_dir(struct buffer_head *dibh, | |||
428 | } | 427 | } |
429 | 428 | ||
430 | /** | 429 | /** |
430 | * gfs2_init_xattr - Initialise an xattr block for a new inode | ||
431 | * @ip: The inode in question | ||
432 | * | ||
433 | * This sets up an empty xattr block for a new inode, ready to | ||
434 | * take any ACLs, LSM xattrs, etc. | ||
435 | */ | ||
436 | |||
437 | static void gfs2_init_xattr(struct gfs2_inode *ip) | ||
438 | { | ||
439 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | ||
440 | struct buffer_head *bh; | ||
441 | struct gfs2_ea_header *ea; | ||
442 | |||
443 | bh = gfs2_meta_new(ip->i_gl, ip->i_eattr); | ||
444 | gfs2_trans_add_meta(ip->i_gl, bh); | ||
445 | gfs2_metatype_set(bh, GFS2_METATYPE_EA, GFS2_FORMAT_EA); | ||
446 | gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header)); | ||
447 | |||
448 | ea = GFS2_EA_BH2FIRST(bh); | ||
449 | ea->ea_rec_len = cpu_to_be32(sdp->sd_jbsize); | ||
450 | ea->ea_type = GFS2_EATYPE_UNUSED; | ||
451 | ea->ea_flags = GFS2_EAFLAG_LAST; | ||
452 | |||
453 | brelse(bh); | ||
454 | } | ||
455 | |||
456 | /** | ||
431 | * init_dinode - Fill in a new dinode structure | 457 | * init_dinode - Fill in a new dinode structure |
432 | * @dip: The directory this inode is being created in | 458 | * @dip: The directory this inode is being created in |
433 | * @ip: The inode | 459 | * @ip: The inode |
@@ -545,13 +571,6 @@ static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, | |||
545 | return err; | 571 | return err; |
546 | } | 572 | } |
547 | 573 | ||
548 | static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip, | ||
549 | const struct qstr *qstr) | ||
550 | { | ||
551 | return security_inode_init_security(&ip->i_inode, &dip->i_inode, qstr, | ||
552 | &gfs2_initxattrs, NULL); | ||
553 | } | ||
554 | |||
555 | /** | 574 | /** |
556 | * gfs2_create_inode - Create a new inode | 575 | * gfs2_create_inode - Create a new inode |
557 | * @dir: The parent directory | 576 | * @dir: The parent directory |
@@ -578,8 +597,9 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
578 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 597 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
579 | struct gfs2_glock *io_gl; | 598 | struct gfs2_glock *io_gl; |
580 | struct dentry *d; | 599 | struct dentry *d; |
581 | int error; | 600 | int error, free_vfs_inode = 0; |
582 | u32 aflags = 0; | 601 | u32 aflags = 0; |
602 | unsigned blocks = 1; | ||
583 | struct gfs2_diradd da = { .bh = NULL, }; | 603 | struct gfs2_diradd da = { .bh = NULL, }; |
584 | 604 | ||
585 | if (!name->len || name->len > GFS2_FNAMESIZE) | 605 | if (!name->len || name->len > GFS2_FNAMESIZE) |
@@ -676,10 +696,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
676 | (dip->i_diskflags & GFS2_DIF_TOPDIR)) | 696 | (dip->i_diskflags & GFS2_DIF_TOPDIR)) |
677 | aflags |= GFS2_AF_ORLOV; | 697 | aflags |= GFS2_AF_ORLOV; |
678 | 698 | ||
679 | error = alloc_dinode(ip, aflags); | 699 | if (default_acl || acl) |
700 | blocks++; | ||
701 | |||
702 | error = alloc_dinode(ip, aflags, &blocks); | ||
680 | if (error) | 703 | if (error) |
681 | goto fail_free_inode; | 704 | goto fail_free_inode; |
682 | 705 | ||
706 | gfs2_set_inode_blocks(inode, blocks); | ||
707 | |||
683 | error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); | 708 | error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); |
684 | if (error) | 709 | if (error) |
685 | goto fail_free_inode; | 710 | goto fail_free_inode; |
@@ -689,10 +714,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
689 | if (error) | 714 | if (error) |
690 | goto fail_free_inode; | 715 | goto fail_free_inode; |
691 | 716 | ||
692 | error = gfs2_trans_begin(sdp, RES_DINODE, 0); | 717 | error = gfs2_trans_begin(sdp, blocks, 0); |
693 | if (error) | 718 | if (error) |
694 | goto fail_gunlock2; | 719 | goto fail_gunlock2; |
695 | 720 | ||
721 | if (blocks > 1) { | ||
722 | ip->i_eattr = ip->i_no_addr + 1; | ||
723 | gfs2_init_xattr(ip); | ||
724 | } | ||
696 | init_dinode(dip, ip, symname); | 725 | init_dinode(dip, ip, symname); |
697 | gfs2_trans_end(sdp); | 726 | gfs2_trans_end(sdp); |
698 | 727 | ||
@@ -722,7 +751,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
722 | if (error) | 751 | if (error) |
723 | goto fail_gunlock3; | 752 | goto fail_gunlock3; |
724 | 753 | ||
725 | error = gfs2_security_init(dip, ip, name); | 754 | error = security_inode_init_security(&ip->i_inode, &dip->i_inode, name, |
755 | &gfs2_initxattrs, NULL); | ||
726 | if (error) | 756 | if (error) |
727 | goto fail_gunlock3; | 757 | goto fail_gunlock3; |
728 | 758 | ||
@@ -758,15 +788,16 @@ fail_free_acls: | |||
758 | if (acl) | 788 | if (acl) |
759 | posix_acl_release(acl); | 789 | posix_acl_release(acl); |
760 | fail_free_vfs_inode: | 790 | fail_free_vfs_inode: |
761 | free_inode_nonrcu(inode); | 791 | free_vfs_inode = 1; |
762 | inode = NULL; | ||
763 | fail_gunlock: | 792 | fail_gunlock: |
764 | gfs2_dir_no_add(&da); | 793 | gfs2_dir_no_add(&da); |
765 | gfs2_glock_dq_uninit(ghs); | 794 | gfs2_glock_dq_uninit(ghs); |
766 | if (inode && !IS_ERR(inode)) { | 795 | if (inode && !IS_ERR(inode)) { |
767 | clear_nlink(inode); | 796 | clear_nlink(inode); |
768 | mark_inode_dirty(inode); | 797 | if (!free_vfs_inode) |
769 | set_bit(GIF_ALLOC_FAILED, &GFS2_I(inode)->i_flags); | 798 | mark_inode_dirty(inode); |
799 | set_bit(free_vfs_inode ? GIF_FREE_VFS_INODE : GIF_ALLOC_FAILED, | ||
800 | &GFS2_I(inode)->i_flags); | ||
770 | iput(inode); | 801 | iput(inode); |
771 | } | 802 | } |
772 | fail: | 803 | fail: |
@@ -1263,6 +1294,10 @@ static int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) | |||
1263 | } | 1294 | } |
1264 | 1295 | ||
1265 | tmp = gfs2_lookupi(dir, &gfs2_qdotdot, 1); | 1296 | tmp = gfs2_lookupi(dir, &gfs2_qdotdot, 1); |
1297 | if (!tmp) { | ||
1298 | error = -ENOENT; | ||
1299 | break; | ||
1300 | } | ||
1266 | if (IS_ERR(tmp)) { | 1301 | if (IS_ERR(tmp)) { |
1267 | error = PTR_ERR(tmp); | 1302 | error = PTR_ERR(tmp); |
1268 | break; | 1303 | break; |