Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2

Pull GFS2 updates from Bob Peterson:
"We only have six patches ready for this merge window:

- Arnd Bergmann contributed a patch that fixes an uninitialized
variable warning.

- The second patch avoids a kernel panic due to referencing an iopen
glock that may not be held, in an error path.

- The third patch fixes a rounding error that caused xfs_tests direct
IO write "fsx" tests to fail on GFS2.

- The fourth patch tidies up the code path when glocks are being
reused to recreate a dinode that was recently deleted.

- The fifth reverts an ages-old patch that should no longer be
needed, and which interfered with the transition of dinodes from
unlinked to free.

- And lastly, a patch to eliminate a function parameter that's not
needed"

* tag 'gfs2-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
GFS2: Eliminate parameter non_block on gfs2_inode_lookup
GFS2: Don't filter out I_FREEING inodes anymore
GFS2: Prevent delete work from occurring on glocks used for create
GFS2: Fix direct IO write rounding error
gfs2: avoid uninitialized variable warning
GFS2: Check if iopen is held when deleting inode

+46 -79
+1 -1
fs/gfs2/aops.c
··· 1082 1082 * the first place, mapping->nr_pages will always be zero. 1083 1083 */ 1084 1084 if (mapping->nrpages) { 1085 - loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); 1085 + loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1); 1086 1086 loff_t len = iov_iter_count(iter); 1087 1087 loff_t end = PAGE_ALIGN(offset + len) - 1; 1088 1088
+3 -3
fs/gfs2/dir.c
··· 798 798 int error; 799 799 800 800 error = get_leaf_nr(dip, index, &leaf_no); 801 - if (!error) 801 + if (!IS_ERR_VALUE(error)) 802 802 error = get_leaf(dip, leaf_no, bh_out); 803 803 804 804 return error; ··· 1014 1014 1015 1015 index = name->hash >> (32 - dip->i_depth); 1016 1016 error = get_leaf_nr(dip, index, &leaf_no); 1017 - if (error) 1017 + if (IS_ERR_VALUE(error)) 1018 1018 return error; 1019 1019 1020 1020 /* Get the old leaf block */ ··· 1660 1660 brelse(bh); 1661 1661 if (fail_on_exist) 1662 1662 return ERR_PTR(-EEXIST); 1663 - inode = gfs2_inode_lookup(dir->i_sb, dtype, addr, formal_ino, 0); 1663 + inode = gfs2_inode_lookup(dir->i_sb, dtype, addr, formal_ino); 1664 1664 if (!IS_ERR(inode)) 1665 1665 GFS2_I(inode)->i_rahead = rahead; 1666 1666 return inode;
+1 -1
fs/gfs2/export.c
··· 137 137 struct gfs2_sbd *sdp = sb->s_fs_info; 138 138 struct inode *inode; 139 139 140 - inode = gfs2_ilookup(sb, inum->no_addr, 0); 140 + inode = gfs2_ilookup(sb, inum->no_addr); 141 141 if (inode) { 142 142 if (GFS2_I(inode)->i_no_formal_ino != inum->no_formal_ino) { 143 143 iput(inode);
+9 -1
fs/gfs2/glock.c
··· 572 572 struct inode *inode; 573 573 u64 no_addr = gl->gl_name.ln_number; 574 574 575 + /* If someone's using this glock to create a new dinode, the block must 576 + have been freed by another node, then re-used, in which case our 577 + iopen callback is too late after the fact. Ignore it. */ 578 + if (test_bit(GLF_INODE_CREATING, &gl->gl_flags)) 579 + goto out; 580 + 575 581 ip = gl->gl_object; 576 582 /* Note: Unsafe to dereference ip as we don't hold right refs/locks */ 577 583 578 584 if (ip) 579 - inode = gfs2_ilookup(sdp->sd_vfs, no_addr, 1); 585 + inode = gfs2_ilookup(sdp->sd_vfs, no_addr); 580 586 else 581 587 inode = gfs2_lookup_by_inum(sdp, no_addr, NULL, GFS2_BLKST_UNLINKED); 582 588 if (inode && !IS_ERR(inode)) { 583 589 d_prune_aliases(inode); 584 590 iput(inode); 585 591 } 592 + out: 586 593 gfs2_glock_put(gl); 587 594 } 588 595 ··· 1022 1015 handle_callback(gl, LM_ST_UNLOCKED, 0, false); 1023 1016 1024 1017 list_del_init(&gh->gh_list); 1018 + clear_bit(HIF_HOLDER, &gh->gh_iflags); 1025 1019 if (find_first_holder(gl) == NULL) { 1026 1020 if (glops->go_unlock) { 1027 1021 GLOCK_BUG_ON(gl, test_and_set_bit(GLF_LOCK, &gl->gl_flags));
+1
fs/gfs2/incore.h
··· 328 328 GLF_LRU = 13, 329 329 GLF_OBJECT = 14, /* Used only for tracing */ 330 330 GLF_BLOCKING = 15, 331 + GLF_INODE_CREATING = 16, /* Inode creation occurring */ 331 332 }; 332 333 333 334 struct gfs2_glock {
+12 -59
fs/gfs2/inode.c
··· 37 37 #include "super.h" 38 38 #include "glops.h" 39 39 40 - struct gfs2_skip_data { 41 - u64 no_addr; 42 - int skipped; 43 - int non_block; 44 - }; 45 - 46 - static int iget_test(struct inode *inode, void *opaque) 40 + struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr) 47 41 { 48 - struct gfs2_inode *ip = GFS2_I(inode); 49 - struct gfs2_skip_data *data = opaque; 50 - 51 - if (ip->i_no_addr == data->no_addr) { 52 - if (data->non_block && 53 - inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { 54 - data->skipped = 1; 55 - return 0; 56 - } 57 - return 1; 58 - } 59 - return 0; 60 - } 61 - 62 - static int iget_set(struct inode *inode, void *opaque) 63 - { 64 - struct gfs2_inode *ip = GFS2_I(inode); 65 - struct gfs2_skip_data *data = opaque; 66 - 67 - if (data->skipped) 68 - return -ENOENT; 69 - inode->i_ino = (unsigned long)(data->no_addr); 70 - ip->i_no_addr = data->no_addr; 71 - return 0; 72 - } 73 - 74 - struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr, int non_block) 75 - { 76 - unsigned long hash = (unsigned long)no_addr; 77 - struct gfs2_skip_data data; 78 - 79 - data.no_addr = no_addr; 80 - data.skipped = 0; 81 - data.non_block = non_block; 82 - return ilookup5(sb, hash, iget_test, &data); 83 - } 84 - 85 - static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr, 86 - int non_block) 87 - { 88 - struct gfs2_skip_data data; 89 - unsigned long hash = (unsigned long)no_addr; 90 - 91 - data.no_addr = no_addr; 92 - data.skipped = 0; 93 - data.non_block = non_block; 94 - return iget5_locked(sb, hash, iget_test, iget_set, &data); 42 + return ilookup(sb, (unsigned long)no_addr); 95 43 } 96 44 97 45 /** ··· 80 132 * @sb: The super block 81 133 * @no_addr: The inode number 82 134 * @type: The type of the inode 83 - * non_block: Can we block on inodes that are being freed? 84 135 * 85 136 * Returns: A VFS inode, or an error 86 137 */ 87 138 88 139 struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, 89 - u64 no_addr, u64 no_formal_ino, int non_block) 140 + u64 no_addr, u64 no_formal_ino) 90 141 { 91 142 struct inode *inode; 92 143 struct gfs2_inode *ip; 93 144 struct gfs2_glock *io_gl = NULL; 94 145 int error; 95 146 96 - inode = gfs2_iget(sb, no_addr, non_block); 147 + inode = iget_locked(sb, (unsigned long)no_addr); 97 148 ip = GFS2_I(inode); 149 + ip->i_no_addr = no_addr; 98 150 99 151 if (!inode) 100 152 return ERR_PTR(-ENOMEM); ··· 169 221 if (error) 170 222 goto fail; 171 223 172 - inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0, 1); 224 + inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0); 173 225 if (IS_ERR(inode)) 174 226 goto fail; 175 227 ··· 540 592 struct inode *inode = NULL; 541 593 struct gfs2_inode *dip = GFS2_I(dir), *ip; 542 594 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 543 - struct gfs2_glock *io_gl; 595 + struct gfs2_glock *io_gl = NULL; 544 596 int error, free_vfs_inode = 1; 545 597 u32 aflags = 0; 546 598 unsigned blocks = 1; ··· 677 729 if (error) 678 730 goto fail_gunlock2; 679 731 732 + BUG_ON(test_and_set_bit(GLF_INODE_CREATING, &io_gl->gl_flags)); 733 + 680 734 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh); 681 735 if (error) 682 736 goto fail_gunlock2; ··· 721 771 } 722 772 gfs2_glock_dq_uninit(ghs); 723 773 gfs2_glock_dq_uninit(ghs + 1); 774 + clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags); 724 775 return error; 725 776 726 777 fail_gunlock3: 727 778 gfs2_glock_dq_uninit(&ip->i_iopen_gh); 728 779 gfs2_glock_put(io_gl); 729 780 fail_gunlock2: 781 + if (io_gl) 782 + clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags); 730 783 gfs2_glock_dq_uninit(ghs + 1); 731 784 fail_free_inode: 732 785 if (ip->i_gl)
+2 -3
fs/gfs2/inode.h
··· 94 94 } 95 95 96 96 extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 97 - u64 no_addr, u64 no_formal_ino, 98 - int non_block); 97 + u64 no_addr, u64 no_formal_ino); 99 98 extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, 100 99 u64 *no_formal_ino, 101 100 unsigned int blktype); 102 - extern struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr, int nonblock); 101 + extern struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr); 103 102 104 103 extern int gfs2_inode_refresh(struct gfs2_inode *ip); 105 104
+1 -1
fs/gfs2/ops_fstype.c
··· 454 454 struct dentry *dentry; 455 455 struct inode *inode; 456 456 457 - inode = gfs2_inode_lookup(sb, DT_DIR, no_addr, 0, 0); 457 + inode = gfs2_inode_lookup(sb, DT_DIR, no_addr, 0); 458 458 if (IS_ERR(inode)) { 459 459 fs_err(sdp, "can't read in %s inode: %ld\n", name, PTR_ERR(inode)); 460 460 return PTR_ERR(inode);
+16 -10
fs/gfs2/super.c
··· 1551 1551 goto out_truncate; 1552 1552 } 1553 1553 1554 - ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1555 - gfs2_glock_dq_wait(&ip->i_iopen_gh); 1556 - gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); 1557 - error = gfs2_glock_nq(&ip->i_iopen_gh); 1558 - if (error) 1559 - goto out_truncate; 1554 + if (ip->i_iopen_gh.gh_gl && 1555 + test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1556 + ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1557 + gfs2_glock_dq_wait(&ip->i_iopen_gh); 1558 + gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, 1559 + &ip->i_iopen_gh); 1560 + error = gfs2_glock_nq(&ip->i_iopen_gh); 1561 + if (error) 1562 + goto out_truncate; 1563 + } 1560 1564 1561 1565 /* Case 1 starts here */ 1562 1566 ··· 1610 1606 if (gfs2_rs_active(&ip->i_res)) 1611 1607 gfs2_rs_deltree(&ip->i_res); 1612 1608 1613 - if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1614 - ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1615 - gfs2_glock_dq_wait(&ip->i_iopen_gh); 1609 + if (ip->i_iopen_gh.gh_gl) { 1610 + if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1611 + ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1612 + gfs2_glock_dq_wait(&ip->i_iopen_gh); 1613 + } 1614 + gfs2_holder_uninit(&ip->i_iopen_gh); 1616 1615 } 1617 - gfs2_holder_uninit(&ip->i_iopen_gh); 1618 1616 gfs2_glock_dq_uninit(&gh); 1619 1617 if (error && error != GLR_TRYFAILED && error != -EROFS) 1620 1618 fs_warn(sdp, "gfs2_evict_inode: %d\n", error);