aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 19:51:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 19:51:32 -0400
commit1ca80a0a3e37d847f3cd6120ca5eb35b39a9a152 (patch)
tree142862af82d881d1b54a949f3887f692c18bbbc9 /fs/gfs2
parentd77bed0d4c61cb0258851367a36b358dbeb7abcc (diff)
parent73b462d2808d7cbca4d7886cf6aaed850640e6cd (diff)
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
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/aops.c2
-rw-r--r--fs/gfs2/dir.c6
-rw-r--r--fs/gfs2/export.c2
-rw-r--r--fs/gfs2/glock.c10
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/inode.c71
-rw-r--r--fs/gfs2/inode.h5
-rw-r--r--fs/gfs2/ops_fstype.c2
-rw-r--r--fs/gfs2/super.c26
9 files changed, 46 insertions, 79 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 93f07465e5a6..aa016e4b8bec 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -1082,7 +1082,7 @@ static ssize_t gfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
1082 * the first place, mapping->nr_pages will always be zero. 1082 * the first place, mapping->nr_pages will always be zero.
1083 */ 1083 */
1084 if (mapping->nrpages) { 1084 if (mapping->nrpages) {
1085 loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); 1085 loff_t lstart = offset & ~(PAGE_CACHE_SIZE - 1);
1086 loff_t len = iov_iter_count(iter); 1086 loff_t len = iov_iter_count(iter);
1087 loff_t end = PAGE_ALIGN(offset + len) - 1; 1087 loff_t end = PAGE_ALIGN(offset + len) - 1;
1088 1088
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 6a92592304fb..4a01f30e9995 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -798,7 +798,7 @@ static int get_first_leaf(struct gfs2_inode *dip, u32 index,
798 int error; 798 int error;
799 799
800 error = get_leaf_nr(dip, index, &leaf_no); 800 error = get_leaf_nr(dip, index, &leaf_no);
801 if (!error) 801 if (!IS_ERR_VALUE(error))
802 error = get_leaf(dip, leaf_no, bh_out); 802 error = get_leaf(dip, leaf_no, bh_out);
803 803
804 return error; 804 return error;
@@ -1014,7 +1014,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1014 1014
1015 index = name->hash >> (32 - dip->i_depth); 1015 index = name->hash >> (32 - dip->i_depth);
1016 error = get_leaf_nr(dip, index, &leaf_no); 1016 error = get_leaf_nr(dip, index, &leaf_no);
1017 if (error) 1017 if (IS_ERR_VALUE(error))
1018 return error; 1018 return error;
1019 1019
1020 /* Get the old leaf block */ 1020 /* Get the old leaf block */
@@ -1660,7 +1660,7 @@ struct inode *gfs2_dir_search(struct inode *dir, const struct qstr *name,
1660 brelse(bh); 1660 brelse(bh);
1661 if (fail_on_exist) 1661 if (fail_on_exist)
1662 return ERR_PTR(-EEXIST); 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 if (!IS_ERR(inode)) 1664 if (!IS_ERR(inode))
1665 GFS2_I(inode)->i_rahead = rahead; 1665 GFS2_I(inode)->i_rahead = rahead;
1666 return inode; 1666 return inode;
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index 5d15e9498b48..d5bda8513457 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -137,7 +137,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,
137 struct gfs2_sbd *sdp = sb->s_fs_info; 137 struct gfs2_sbd *sdp = sb->s_fs_info;
138 struct inode *inode; 138 struct inode *inode;
139 139
140 inode = gfs2_ilookup(sb, inum->no_addr, 0); 140 inode = gfs2_ilookup(sb, inum->no_addr);
141 if (inode) { 141 if (inode) {
142 if (GFS2_I(inode)->i_no_formal_ino != inum->no_formal_ino) { 142 if (GFS2_I(inode)->i_no_formal_ino != inum->no_formal_ino) {
143 iput(inode); 143 iput(inode);
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index a4ff7b56f5cd..6539131c52a2 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -572,17 +572,24 @@ static void delete_work_func(struct work_struct *work)
572 struct inode *inode; 572 struct inode *inode;
573 u64 no_addr = gl->gl_name.ln_number; 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 ip = gl->gl_object; 581 ip = gl->gl_object;
576 /* Note: Unsafe to dereference ip as we don't hold right refs/locks */ 582 /* Note: Unsafe to dereference ip as we don't hold right refs/locks */
577 583
578 if (ip) 584 if (ip)
579 inode = gfs2_ilookup(sdp->sd_vfs, no_addr, 1); 585 inode = gfs2_ilookup(sdp->sd_vfs, no_addr);
580 else 586 else
581 inode = gfs2_lookup_by_inum(sdp, no_addr, NULL, GFS2_BLKST_UNLINKED); 587 inode = gfs2_lookup_by_inum(sdp, no_addr, NULL, GFS2_BLKST_UNLINKED);
582 if (inode && !IS_ERR(inode)) { 588 if (inode && !IS_ERR(inode)) {
583 d_prune_aliases(inode); 589 d_prune_aliases(inode);
584 iput(inode); 590 iput(inode);
585 } 591 }
592out:
586 gfs2_glock_put(gl); 593 gfs2_glock_put(gl);
587} 594}
588 595
@@ -1015,6 +1022,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
1015 handle_callback(gl, LM_ST_UNLOCKED, 0, false); 1022 handle_callback(gl, LM_ST_UNLOCKED, 0, false);
1016 1023
1017 list_del_init(&gh->gh_list); 1024 list_del_init(&gh->gh_list);
1025 clear_bit(HIF_HOLDER, &gh->gh_iflags);
1018 if (find_first_holder(gl) == NULL) { 1026 if (find_first_holder(gl) == NULL) {
1019 if (glops->go_unlock) { 1027 if (glops->go_unlock) {
1020 GLOCK_BUG_ON(gl, test_and_set_bit(GLF_LOCK, &gl->gl_flags)); 1028 GLOCK_BUG_ON(gl, test_and_set_bit(GLF_LOCK, &gl->gl_flags));
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 845fb09cc606..a6a3389a07fc 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -328,6 +328,7 @@ enum {
328 GLF_LRU = 13, 328 GLF_LRU = 13,
329 GLF_OBJECT = 14, /* Used only for tracing */ 329 GLF_OBJECT = 14, /* Used only for tracing */
330 GLF_BLOCKING = 15, 330 GLF_BLOCKING = 15,
331 GLF_INODE_CREATING = 16, /* Inode creation occurring */
331}; 332};
332 333
333struct gfs2_glock { 334struct gfs2_glock {
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 352f958769e1..bb30f9a72c65 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -37,61 +37,9 @@
37#include "super.h" 37#include "super.h"
38#include "glops.h" 38#include "glops.h"
39 39
40struct gfs2_skip_data { 40struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr)
41 u64 no_addr;
42 int skipped;
43 int non_block;
44};
45
46static int iget_test(struct inode *inode, void *opaque)
47{
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
62static 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
74struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr, int non_block)
75{ 41{
76 unsigned long hash = (unsigned long)no_addr; 42 return ilookup(sb, (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
85static 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);
95} 43}
96 44
97/** 45/**
@@ -132,21 +80,21 @@ static void gfs2_set_iop(struct inode *inode)
132 * @sb: The super block 80 * @sb: The super block
133 * @no_addr: The inode number 81 * @no_addr: The inode number
134 * @type: The type of the inode 82 * @type: The type of the inode
135 * non_block: Can we block on inodes that are being freed?
136 * 83 *
137 * Returns: A VFS inode, or an error 84 * Returns: A VFS inode, or an error
138 */ 85 */
139 86
140struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, 87struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
141 u64 no_addr, u64 no_formal_ino, int non_block) 88 u64 no_addr, u64 no_formal_ino)
142{ 89{
143 struct inode *inode; 90 struct inode *inode;
144 struct gfs2_inode *ip; 91 struct gfs2_inode *ip;
145 struct gfs2_glock *io_gl = NULL; 92 struct gfs2_glock *io_gl = NULL;
146 int error; 93 int error;
147 94
148 inode = gfs2_iget(sb, no_addr, non_block); 95 inode = iget_locked(sb, (unsigned long)no_addr);
149 ip = GFS2_I(inode); 96 ip = GFS2_I(inode);
97 ip->i_no_addr = no_addr;
150 98
151 if (!inode) 99 if (!inode)
152 return ERR_PTR(-ENOMEM); 100 return ERR_PTR(-ENOMEM);
@@ -221,7 +169,7 @@ struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
221 if (error) 169 if (error)
222 goto fail; 170 goto fail;
223 171
224 inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0, 1); 172 inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, 0);
225 if (IS_ERR(inode)) 173 if (IS_ERR(inode))
226 goto fail; 174 goto fail;
227 175
@@ -592,7 +540,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
592 struct inode *inode = NULL; 540 struct inode *inode = NULL;
593 struct gfs2_inode *dip = GFS2_I(dir), *ip; 541 struct gfs2_inode *dip = GFS2_I(dir), *ip;
594 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 542 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
595 struct gfs2_glock *io_gl; 543 struct gfs2_glock *io_gl = NULL;
596 int error, free_vfs_inode = 1; 544 int error, free_vfs_inode = 1;
597 u32 aflags = 0; 545 u32 aflags = 0;
598 unsigned blocks = 1; 546 unsigned blocks = 1;
@@ -729,6 +677,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
729 if (error) 677 if (error)
730 goto fail_gunlock2; 678 goto fail_gunlock2;
731 679
680 BUG_ON(test_and_set_bit(GLF_INODE_CREATING, &io_gl->gl_flags));
681
732 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh); 682 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
733 if (error) 683 if (error)
734 goto fail_gunlock2; 684 goto fail_gunlock2;
@@ -771,12 +721,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
771 } 721 }
772 gfs2_glock_dq_uninit(ghs); 722 gfs2_glock_dq_uninit(ghs);
773 gfs2_glock_dq_uninit(ghs + 1); 723 gfs2_glock_dq_uninit(ghs + 1);
724 clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
774 return error; 725 return error;
775 726
776fail_gunlock3: 727fail_gunlock3:
777 gfs2_glock_dq_uninit(&ip->i_iopen_gh); 728 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
778 gfs2_glock_put(io_gl); 729 gfs2_glock_put(io_gl);
779fail_gunlock2: 730fail_gunlock2:
731 if (io_gl)
732 clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
780 gfs2_glock_dq_uninit(ghs + 1); 733 gfs2_glock_dq_uninit(ghs + 1);
781fail_free_inode: 734fail_free_inode:
782 if (ip->i_gl) 735 if (ip->i_gl)
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index ba4d9492d422..e1af0d4aa308 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -94,12 +94,11 @@ err:
94} 94}
95 95
96extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 96extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
97 u64 no_addr, u64 no_formal_ino, 97 u64 no_addr, u64 no_formal_ino);
98 int non_block);
99extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, 98extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
100 u64 *no_formal_ino, 99 u64 *no_formal_ino,
101 unsigned int blktype); 100 unsigned int blktype);
102extern struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr, int nonblock); 101extern struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr);
103 102
104extern int gfs2_inode_refresh(struct gfs2_inode *ip); 103extern int gfs2_inode_refresh(struct gfs2_inode *ip);
105 104
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index dbed9e243ea2..49b0bff18fe3 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -454,7 +454,7 @@ static int gfs2_lookup_root(struct super_block *sb, struct dentry **dptr,
454 struct dentry *dentry; 454 struct dentry *dentry;
455 struct inode *inode; 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 if (IS_ERR(inode)) { 458 if (IS_ERR(inode)) {
459 fs_err(sdp, "can't read in %s inode: %ld\n", name, PTR_ERR(inode)); 459 fs_err(sdp, "can't read in %s inode: %ld\n", name, PTR_ERR(inode));
460 return PTR_ERR(inode); 460 return PTR_ERR(inode);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 8f960a51a9a0..f8a0cd821290 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1551,12 +1551,16 @@ static void gfs2_evict_inode(struct inode *inode)
1551 goto out_truncate; 1551 goto out_truncate;
1552 } 1552 }
1553 1553
1554 ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1554 if (ip->i_iopen_gh.gh_gl &&
1555 gfs2_glock_dq_wait(&ip->i_iopen_gh); 1555 test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1556 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); 1556 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1557 error = gfs2_glock_nq(&ip->i_iopen_gh); 1557 gfs2_glock_dq_wait(&ip->i_iopen_gh);
1558 if (error) 1558 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE,
1559 goto out_truncate; 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 /* Case 1 starts here */ 1565 /* Case 1 starts here */
1562 1566
@@ -1606,11 +1610,13 @@ out_unlock:
1606 if (gfs2_rs_active(&ip->i_res)) 1610 if (gfs2_rs_active(&ip->i_res))
1607 gfs2_rs_deltree(&ip->i_res); 1611 gfs2_rs_deltree(&ip->i_res);
1608 1612
1609 if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) { 1613 if (ip->i_iopen_gh.gh_gl) {
1610 ip->i_iopen_gh.gh_flags |= GL_NOCACHE; 1614 if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1611 gfs2_glock_dq_wait(&ip->i_iopen_gh); 1615 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1616 gfs2_glock_dq_wait(&ip->i_iopen_gh);
1617 }
1618 gfs2_holder_uninit(&ip->i_iopen_gh);
1612 } 1619 }
1613 gfs2_holder_uninit(&ip->i_iopen_gh);
1614 gfs2_glock_dq_uninit(&gh); 1620 gfs2_glock_dq_uninit(&gh);
1615 if (error && error != GLR_TRYFAILED && error != -EROFS) 1621 if (error && error != GLR_TRYFAILED && error != -EROFS)
1616 fs_warn(sdp, "gfs2_evict_inode: %d\n", error); 1622 fs_warn(sdp, "gfs2_evict_inode: %d\n", error);