aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/acl.c1
-rw-r--r--fs/ocfs2/buffer_head_io.c3
-rw-r--r--fs/ocfs2/cluster/heartbeat.c1
-rw-r--r--fs/ocfs2/cluster/nodemanager.c1
-rw-r--r--fs/ocfs2/cluster/quorum.c1
-rw-r--r--fs/ocfs2/dlm/dlmast.c6
-rw-r--r--fs/ocfs2/dlm/dlmconvert.c1
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c4
-rw-r--r--fs/ocfs2/dlm/dlmthread.c1
-rw-r--r--fs/ocfs2/dlm/dlmunlock.c1
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c14
-rw-r--r--fs/ocfs2/extent_map.c1
-rw-r--r--fs/ocfs2/file.c32
-rw-r--r--fs/ocfs2/heartbeat.c1
-rw-r--r--fs/ocfs2/inode.c84
-rw-r--r--fs/ocfs2/inode.h2
-rw-r--r--fs/ocfs2/mmap.c1
-rw-r--r--fs/ocfs2/namei.c86
-rw-r--r--fs/ocfs2/quota_global.c1
-rw-r--r--fs/ocfs2/quota_local.c1
-rw-r--r--fs/ocfs2/refcounttree.c4
-rw-r--r--fs/ocfs2/stack_o2cb.c1
-rw-r--r--fs/ocfs2/stack_user.c1
-rw-r--r--fs/ocfs2/sysfile.c1
24 files changed, 157 insertions, 93 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 8ccf0f8c9cc8..e13fc9e8fcdc 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24#include <linux/string.h> 25#include <linux/string.h>
25 26
26#define MLOG_MASK_PREFIX ML_INODE 27#define MLOG_MASK_PREFIX ML_INODE
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index 21c808f752d8..f9d5d3ffc75a 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/slab.h>
29#include <linux/highmem.h> 28#include <linux/highmem.h>
30 29
31#include <cluster/masklog.h> 30#include <cluster/masklog.h>
@@ -407,6 +406,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
407 struct buffer_head *bh) 406 struct buffer_head *bh)
408{ 407{
409 int ret = 0; 408 int ret = 0;
409 struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
410 410
411 mlog_entry_void(); 411 mlog_entry_void();
412 412
@@ -426,6 +426,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
426 426
427 get_bh(bh); /* for end_buffer_write_sync() */ 427 get_bh(bh); /* for end_buffer_write_sync() */
428 bh->b_end_io = end_buffer_write_sync; 428 bh->b_end_io = end_buffer_write_sync;
429 ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &di->i_check);
429 submit_bh(WRITE, bh); 430 submit_bh(WRITE, bh);
430 431
431 wait_on_buffer(bh); 432 wait_on_buffer(bh);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 5c9890006708..41d5f1f92d56 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -34,6 +34,7 @@
34#include <linux/crc32.h> 34#include <linux/crc32.h>
35#include <linux/time.h> 35#include <linux/time.h>
36#include <linux/debugfs.h> 36#include <linux/debugfs.h>
37#include <linux/slab.h>
37 38
38#include "heartbeat.h" 39#include "heartbeat.h"
39#include "tcp.h" 40#include "tcp.h"
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index c81142e3ef84..ed0c9f367fed 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -19,6 +19,7 @@
19 * Boston, MA 021110-1307, USA. 19 * Boston, MA 021110-1307, USA.
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/configfs.h> 25#include <linux/configfs.h>
diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c
index 639024033fce..cf3e16696216 100644
--- a/fs/ocfs2/cluster/quorum.c
+++ b/fs/ocfs2/cluster/quorum.c
@@ -44,7 +44,6 @@
44 * and if they're the last, they fire off the decision. 44 * and if they're the last, they fire off the decision.
45 */ 45 */
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/slab.h>
48#include <linux/workqueue.h> 47#include <linux/workqueue.h>
49#include <linux/reboot.h> 48#include <linux/reboot.h>
50 49
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index 7ec61d91b6a4..f44999156839 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/slab.h>
32#include <linux/highmem.h> 31#include <linux/highmem.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/sysctl.h> 33#include <linux/sysctl.h>
@@ -185,9 +184,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
185 BUG_ON(!lksb); 184 BUG_ON(!lksb);
186 185
187 /* only updates if this node masters the lockres */ 186 /* only updates if this node masters the lockres */
187 spin_lock(&res->spinlock);
188 if (res->owner == dlm->node_num) { 188 if (res->owner == dlm->node_num) {
189
190 spin_lock(&res->spinlock);
191 /* check the lksb flags for the direction */ 189 /* check the lksb flags for the direction */
192 if (lksb->flags & DLM_LKSB_GET_LVB) { 190 if (lksb->flags & DLM_LKSB_GET_LVB) {
193 mlog(0, "getting lvb from lockres for %s node\n", 191 mlog(0, "getting lvb from lockres for %s node\n",
@@ -202,8 +200,8 @@ static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
202 * here. In the future we might want to clear it at the time 200 * here. In the future we might want to clear it at the time
203 * the put is actually done. 201 * the put is actually done.
204 */ 202 */
205 spin_unlock(&res->spinlock);
206 } 203 }
204 spin_unlock(&res->spinlock);
207 205
208 /* reset any lvb flags on the lksb */ 206 /* reset any lvb flags on the lksb */
209 lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB); 207 lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB);
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c
index 3028d05fc4e9..9f30491e5e88 100644
--- a/fs/ocfs2/dlm/dlmconvert.c
+++ b/fs/ocfs2/dlm/dlmconvert.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/slab.h>
32#include <linux/highmem.h> 31#include <linux/highmem.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/sysctl.h> 33#include <linux/sysctl.h>
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index b01e34819a09..4a7506a4e314 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -1873,7 +1873,6 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
1873ok: 1873ok:
1874 spin_unlock(&res->spinlock); 1874 spin_unlock(&res->spinlock);
1875 } 1875 }
1876 spin_unlock(&dlm->spinlock);
1877 1876
1878 // mlog(0, "woo! got an assert_master from node %u!\n", 1877 // mlog(0, "woo! got an assert_master from node %u!\n",
1879 // assert->node_idx); 1878 // assert->node_idx);
@@ -1924,7 +1923,6 @@ ok:
1924 /* master is known, detach if not already detached. 1923 /* master is known, detach if not already detached.
1925 * ensures that only one assert_master call will happen 1924 * ensures that only one assert_master call will happen
1926 * on this mle. */ 1925 * on this mle. */
1927 spin_lock(&dlm->spinlock);
1928 spin_lock(&dlm->master_lock); 1926 spin_lock(&dlm->master_lock);
1929 1927
1930 rr = atomic_read(&mle->mle_refs.refcount); 1928 rr = atomic_read(&mle->mle_refs.refcount);
@@ -1957,7 +1955,6 @@ ok:
1957 __dlm_put_mle(mle); 1955 __dlm_put_mle(mle);
1958 } 1956 }
1959 spin_unlock(&dlm->master_lock); 1957 spin_unlock(&dlm->master_lock);
1960 spin_unlock(&dlm->spinlock);
1961 } else if (res) { 1958 } else if (res) {
1962 if (res->owner != assert->node_idx) { 1959 if (res->owner != assert->node_idx) {
1963 mlog(0, "assert_master from %u, but current " 1960 mlog(0, "assert_master from %u, but current "
@@ -1965,6 +1962,7 @@ ok:
1965 res->owner, namelen, name); 1962 res->owner, namelen, name);
1966 } 1963 }
1967 } 1964 }
1965 spin_unlock(&dlm->spinlock);
1968 1966
1969done: 1967done:
1970 ret = 0; 1968 ret = 0;
diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c
index 0bdd28e1d4d9..d4f73ca68fe5 100644
--- a/fs/ocfs2/dlm/dlmthread.c
+++ b/fs/ocfs2/dlm/dlmthread.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/slab.h>
32#include <linux/highmem.h> 31#include <linux/highmem.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/sysctl.h> 33#include <linux/sysctl.h>
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 2c1f306f8fa5..817287c6a6db 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/slab.h>
32#include <linux/highmem.h> 31#include <linux/highmem.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/sysctl.h> 33#include <linux/sysctl.h>
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 1b0de157a08c..b83d6107a1f5 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -112,20 +112,20 @@ MODULE_PARM_DESC(capabilities, DLMFS_CAPABILITIES);
112 * O_RDONLY -> PRMODE level 112 * O_RDONLY -> PRMODE level
113 * O_WRONLY -> EXMODE level 113 * O_WRONLY -> EXMODE level
114 * 114 *
115 * O_NONBLOCK -> LKM_NOQUEUE 115 * O_NONBLOCK -> NOQUEUE
116 */ 116 */
117static int dlmfs_decode_open_flags(int open_flags, 117static int dlmfs_decode_open_flags(int open_flags,
118 int *level, 118 int *level,
119 int *flags) 119 int *flags)
120{ 120{
121 if (open_flags & (O_WRONLY|O_RDWR)) 121 if (open_flags & (O_WRONLY|O_RDWR))
122 *level = LKM_EXMODE; 122 *level = DLM_LOCK_EX;
123 else 123 else
124 *level = LKM_PRMODE; 124 *level = DLM_LOCK_PR;
125 125
126 *flags = 0; 126 *flags = 0;
127 if (open_flags & O_NONBLOCK) 127 if (open_flags & O_NONBLOCK)
128 *flags |= LKM_NOQUEUE; 128 *flags |= DLM_LKF_NOQUEUE;
129 129
130 return 0; 130 return 0;
131} 131}
@@ -166,7 +166,7 @@ static int dlmfs_file_open(struct inode *inode,
166 * to be able userspace to be able to distinguish a 166 * to be able userspace to be able to distinguish a
167 * valid lock request from one that simply couldn't be 167 * valid lock request from one that simply couldn't be
168 * granted. */ 168 * granted. */
169 if (flags & LKM_NOQUEUE && status == -EAGAIN) 169 if (flags & DLM_LKF_NOQUEUE && status == -EAGAIN)
170 status = -ETXTBSY; 170 status = -ETXTBSY;
171 kfree(fp); 171 kfree(fp);
172 goto bail; 172 goto bail;
@@ -193,7 +193,7 @@ static int dlmfs_file_release(struct inode *inode,
193 status = 0; 193 status = 0;
194 if (fp) { 194 if (fp) {
195 level = fp->fp_lock_level; 195 level = fp->fp_lock_level;
196 if (level != LKM_IVMODE) 196 if (level != DLM_LOCK_IV)
197 user_dlm_cluster_unlock(&ip->ip_lockres, level); 197 user_dlm_cluster_unlock(&ip->ip_lockres, level);
198 198
199 kfree(fp); 199 kfree(fp);
@@ -262,7 +262,7 @@ static ssize_t dlmfs_file_read(struct file *filp,
262 if ((count + *ppos) > i_size_read(inode)) 262 if ((count + *ppos) > i_size_read(inode))
263 readlen = i_size_read(inode) - *ppos; 263 readlen = i_size_read(inode) - *ppos;
264 else 264 else
265 readlen = count - *ppos; 265 readlen = count;
266 266
267 lvb_buf = kmalloc(readlen, GFP_NOFS); 267 lvb_buf = kmalloc(readlen, GFP_NOFS);
268 if (!lvb_buf) 268 if (!lvb_buf)
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index c562a7581cf9..09e3fdfa6d33 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/slab.h>
27#include <linux/types.h> 28#include <linux/types.h>
28#include <linux/fiemap.h> 29#include <linux/fiemap.h>
29 30
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9c1047c2e44e..f74f1400eccd 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -671,6 +671,7 @@ restarted_transaction:
671 if (why == RESTART_META) { 671 if (why == RESTART_META) {
672 mlog(0, "restarting function.\n"); 672 mlog(0, "restarting function.\n");
673 restart_func = 1; 673 restart_func = 1;
674 status = 0;
674 } else { 675 } else {
675 BUG_ON(why != RESTART_TRANS); 676 BUG_ON(why != RESTART_TRANS);
676 677
@@ -2106,18 +2107,18 @@ relock:
2106 /* communicate with ocfs2_dio_end_io */ 2107 /* communicate with ocfs2_dio_end_io */
2107 ocfs2_iocb_set_rw_locked(iocb, rw_level); 2108 ocfs2_iocb_set_rw_locked(iocb, rw_level);
2108 2109
2109 if (direct_io) { 2110 ret = generic_segment_checks(iov, &nr_segs, &ocount,
2110 ret = generic_segment_checks(iov, &nr_segs, &ocount, 2111 VERIFY_READ);
2111 VERIFY_READ); 2112 if (ret)
2112 if (ret) 2113 goto out_dio;
2113 goto out_dio;
2114 2114
2115 count = ocount; 2115 count = ocount;
2116 ret = generic_write_checks(file, ppos, &count, 2116 ret = generic_write_checks(file, ppos, &count,
2117 S_ISBLK(inode->i_mode)); 2117 S_ISBLK(inode->i_mode));
2118 if (ret) 2118 if (ret)
2119 goto out_dio; 2119 goto out_dio;
2120 2120
2121 if (direct_io) {
2121 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos, 2122 written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
2122 ppos, count, ocount); 2123 ppos, count, ocount);
2123 if (written < 0) { 2124 if (written < 0) {
@@ -2132,7 +2133,10 @@ relock:
2132 goto out_dio; 2133 goto out_dio;
2133 } 2134 }
2134 } else { 2135 } else {
2135 written = __generic_file_aio_write(iocb, iov, nr_segs, ppos); 2136 current->backing_dev_info = file->f_mapping->backing_dev_info;
2137 written = generic_file_buffered_write(iocb, iov, nr_segs, *ppos,
2138 ppos, count, 0);
2139 current->backing_dev_info = NULL;
2136 } 2140 }
2137 2141
2138out_dio: 2142out_dio:
@@ -2146,9 +2150,9 @@ out_dio:
2146 if (ret < 0) 2150 if (ret < 0)
2147 written = ret; 2151 written = ret;
2148 2152
2149 if (!ret && (old_size != i_size_read(inode) || 2153 if (!ret && ((old_size != i_size_read(inode)) ||
2150 old_clusters != OCFS2_I(inode)->ip_clusters || 2154 (old_clusters != OCFS2_I(inode)->ip_clusters) ||
2151 has_refcount)) { 2155 has_refcount)) {
2152 ret = jbd2_journal_force_commit(osb->journal->j_journal); 2156 ret = jbd2_journal_force_commit(osb->journal->j_journal);
2153 if (ret < 0) 2157 if (ret < 0)
2154 written = ret; 2158 written = ret;
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c
index c6e7213db868..1aa863dd901f 100644
--- a/fs/ocfs2/heartbeat.c
+++ b/fs/ocfs2/heartbeat.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/slab.h>
30#include <linux/highmem.h> 29#include <linux/highmem.h>
31 30
32#define MLOG_MASK_PREFIX ML_SUPER 31#define MLOG_MASK_PREFIX ML_SUPER
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 9a17251f3d9e..abb0a95cc717 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/slab.h>
29#include <linux/highmem.h> 28#include <linux/highmem.h>
30#include <linux/pagemap.h> 29#include <linux/pagemap.h>
31#include <linux/quotaops.h> 30#include <linux/quotaops.h>
@@ -562,6 +561,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
562 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); 561 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
563 if (IS_ERR(handle)) { 562 if (IS_ERR(handle)) {
564 status = PTR_ERR(handle); 563 status = PTR_ERR(handle);
564 handle = NULL;
565 mlog_errno(status); 565 mlog_errno(status);
566 goto out; 566 goto out;
567 } 567 }
@@ -637,11 +637,13 @@ static int ocfs2_remove_inode(struct inode *inode,
637 goto bail_unlock; 637 goto bail_unlock;
638 } 638 }
639 639
640 status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode, 640 if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) {
641 orphan_dir_bh); 641 status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode,
642 if (status < 0) { 642 orphan_dir_bh);
643 mlog_errno(status); 643 if (status < 0) {
644 goto bail_commit; 644 mlog_errno(status);
645 goto bail_commit;
646 }
645 } 647 }
646 648
647 /* set the inodes dtime */ 649 /* set the inodes dtime */
@@ -715,38 +717,39 @@ static void ocfs2_signal_wipe_completion(struct ocfs2_super *osb,
715static int ocfs2_wipe_inode(struct inode *inode, 717static int ocfs2_wipe_inode(struct inode *inode,
716 struct buffer_head *di_bh) 718 struct buffer_head *di_bh)
717{ 719{
718 int status, orphaned_slot; 720 int status, orphaned_slot = -1;
719 struct inode *orphan_dir_inode = NULL; 721 struct inode *orphan_dir_inode = NULL;
720 struct buffer_head *orphan_dir_bh = NULL; 722 struct buffer_head *orphan_dir_bh = NULL;
721 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 723 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
722 struct ocfs2_dinode *di; 724 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
723 725
724 di = (struct ocfs2_dinode *) di_bh->b_data; 726 if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) {
725 orphaned_slot = le16_to_cpu(di->i_orphaned_slot); 727 orphaned_slot = le16_to_cpu(di->i_orphaned_slot);
726 728
727 status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot); 729 status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot);
728 if (status) 730 if (status)
729 return status; 731 return status;
730 732
731 orphan_dir_inode = ocfs2_get_system_file_inode(osb, 733 orphan_dir_inode = ocfs2_get_system_file_inode(osb,
732 ORPHAN_DIR_SYSTEM_INODE, 734 ORPHAN_DIR_SYSTEM_INODE,
733 orphaned_slot); 735 orphaned_slot);
734 if (!orphan_dir_inode) { 736 if (!orphan_dir_inode) {
735 status = -EEXIST; 737 status = -EEXIST;
736 mlog_errno(status); 738 mlog_errno(status);
737 goto bail; 739 goto bail;
738 } 740 }
739 741
740 /* Lock the orphan dir. The lock will be held for the entire 742 /* Lock the orphan dir. The lock will be held for the entire
741 * delete_inode operation. We do this now to avoid races with 743 * delete_inode operation. We do this now to avoid races with
742 * recovery completion on other nodes. */ 744 * recovery completion on other nodes. */
743 mutex_lock(&orphan_dir_inode->i_mutex); 745 mutex_lock(&orphan_dir_inode->i_mutex);
744 status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1); 746 status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
745 if (status < 0) { 747 if (status < 0) {
746 mutex_unlock(&orphan_dir_inode->i_mutex); 748 mutex_unlock(&orphan_dir_inode->i_mutex);
747 749
748 mlog_errno(status); 750 mlog_errno(status);
749 goto bail; 751 goto bail;
752 }
750 } 753 }
751 754
752 /* we do this while holding the orphan dir lock because we 755 /* we do this while holding the orphan dir lock because we
@@ -787,6 +790,9 @@ static int ocfs2_wipe_inode(struct inode *inode,
787 mlog_errno(status); 790 mlog_errno(status);
788 791
789bail_unlock_dir: 792bail_unlock_dir:
793 if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)
794 return status;
795
790 ocfs2_inode_unlock(orphan_dir_inode, 1); 796 ocfs2_inode_unlock(orphan_dir_inode, 1);
791 mutex_unlock(&orphan_dir_inode->i_mutex); 797 mutex_unlock(&orphan_dir_inode->i_mutex);
792 brelse(orphan_dir_bh); 798 brelse(orphan_dir_bh);
@@ -882,7 +888,23 @@ static int ocfs2_query_inode_wipe(struct inode *inode,
882 888
883 /* Do some basic inode verification... */ 889 /* Do some basic inode verification... */
884 di = (struct ocfs2_dinode *) di_bh->b_data; 890 di = (struct ocfs2_dinode *) di_bh->b_data;
885 if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL))) { 891 if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL)) &&
892 !(oi->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) {
893 /*
894 * Inodes in the orphan dir must have ORPHANED_FL. The only
895 * inodes that come back out of the orphan dir are reflink
896 * targets. A reflink target may be moved out of the orphan
897 * dir between the time we scan the directory and the time we
898 * process it. This would lead to HAS_REFCOUNT_FL being set but
899 * ORPHANED_FL not.
900 */
901 if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) {
902 mlog(0, "Reflinked inode %llu is no longer orphaned. "
903 "it shouldn't be deleted\n",
904 (unsigned long long)oi->ip_blkno);
905 goto bail;
906 }
907
886 /* for lack of a better error? */ 908 /* for lack of a better error? */
887 status = -EEXIST; 909 status = -EEXIST;
888 mlog(ML_ERROR, 910 mlog(ML_ERROR,
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index e45edca02594..9f5f5fcadc45 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -102,6 +102,8 @@ struct ocfs2_inode_info
102#define OCFS2_INODE_MAYBE_ORPHANED 0x00000020 102#define OCFS2_INODE_MAYBE_ORPHANED 0x00000020
103/* Does someone have the file open O_DIRECT */ 103/* Does someone have the file open O_DIRECT */
104#define OCFS2_INODE_OPEN_DIRECT 0x00000040 104#define OCFS2_INODE_OPEN_DIRECT 0x00000040
105/* Tell the inode wipe code it's not in orphan dir */
106#define OCFS2_INODE_SKIP_ORPHAN_DIR 0x00000080
105 107
106static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode) 108static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
107{ 109{
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index a61809f8eab5..af2b8fe1f139 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/slab.h>
29#include <linux/highmem.h> 28#include <linux/highmem.h>
30#include <linux/pagemap.h> 29#include <linux/pagemap.h>
31#include <linux/uio.h> 30#include <linux/uio.h>
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index b0fa6b650751..db5dd3ed4df4 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -84,7 +84,7 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
84static int ocfs2_orphan_add(struct ocfs2_super *osb, 84static int ocfs2_orphan_add(struct ocfs2_super *osb,
85 handle_t *handle, 85 handle_t *handle,
86 struct inode *inode, 86 struct inode *inode,
87 struct ocfs2_dinode *fe, 87 struct buffer_head *fe_bh,
88 char *name, 88 char *name,
89 struct ocfs2_dir_lookup_result *lookup, 89 struct ocfs2_dir_lookup_result *lookup,
90 struct inode *orphan_dir_inode); 90 struct inode *orphan_dir_inode);
@@ -410,23 +410,28 @@ static int ocfs2_mknod(struct inode *dir,
410 } 410 }
411 } 411 }
412 412
413 status = ocfs2_add_entry(handle, dentry, inode, 413 /*
414 OCFS2_I(inode)->ip_blkno, parent_fe_bh, 414 * Do this before adding the entry to the directory. We add
415 &lookup); 415 * also set d_op after success so that ->d_iput() will cleanup
416 if (status < 0) { 416 * the dentry lock even if ocfs2_add_entry() fails below.
417 */
418 status = ocfs2_dentry_attach_lock(dentry, inode,
419 OCFS2_I(dir)->ip_blkno);
420 if (status) {
417 mlog_errno(status); 421 mlog_errno(status);
418 goto leave; 422 goto leave;
419 } 423 }
424 dentry->d_op = &ocfs2_dentry_ops;
420 425
421 status = ocfs2_dentry_attach_lock(dentry, inode, 426 status = ocfs2_add_entry(handle, dentry, inode,
422 OCFS2_I(dir)->ip_blkno); 427 OCFS2_I(inode)->ip_blkno, parent_fe_bh,
423 if (status) { 428 &lookup);
429 if (status < 0) {
424 mlog_errno(status); 430 mlog_errno(status);
425 goto leave; 431 goto leave;
426 } 432 }
427 433
428 insert_inode_hash(inode); 434 insert_inode_hash(inode);
429 dentry->d_op = &ocfs2_dentry_ops;
430 d_instantiate(dentry, inode); 435 d_instantiate(dentry, inode);
431 status = 0; 436 status = 0;
432leave: 437leave:
@@ -449,11 +454,6 @@ leave:
449 454
450 ocfs2_free_dir_lookup_result(&lookup); 455 ocfs2_free_dir_lookup_result(&lookup);
451 456
452 if ((status < 0) && inode) {
453 clear_nlink(inode);
454 iput(inode);
455 }
456
457 if (inode_ac) 457 if (inode_ac)
458 ocfs2_free_alloc_context(inode_ac); 458 ocfs2_free_alloc_context(inode_ac);
459 459
@@ -463,6 +463,17 @@ leave:
463 if (meta_ac) 463 if (meta_ac)
464 ocfs2_free_alloc_context(meta_ac); 464 ocfs2_free_alloc_context(meta_ac);
465 465
466 /*
467 * We should call iput after the i_mutex of the bitmap been
468 * unlocked in ocfs2_free_alloc_context, or the
469 * ocfs2_delete_inode will mutex_lock again.
470 */
471 if ((status < 0) && inode) {
472 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR;
473 clear_nlink(inode);
474 iput(inode);
475 }
476
466 mlog_exit(status); 477 mlog_exit(status);
467 478
468 return status; 479 return status;
@@ -879,7 +890,7 @@ static int ocfs2_unlink(struct inode *dir,
879 fe = (struct ocfs2_dinode *) fe_bh->b_data; 890 fe = (struct ocfs2_dinode *) fe_bh->b_data;
880 891
881 if (inode_is_unlinkable(inode)) { 892 if (inode_is_unlinkable(inode)) {
882 status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, 893 status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name,
883 &orphan_insert, orphan_dir); 894 &orphan_insert, orphan_dir);
884 if (status < 0) { 895 if (status < 0) {
885 mlog_errno(status); 896 mlog_errno(status);
@@ -1295,7 +1306,7 @@ static int ocfs2_rename(struct inode *old_dir,
1295 if (S_ISDIR(new_inode->i_mode) || 1306 if (S_ISDIR(new_inode->i_mode) ||
1296 (ocfs2_read_links_count(newfe) == 1)) { 1307 (ocfs2_read_links_count(newfe) == 1)) {
1297 status = ocfs2_orphan_add(osb, handle, new_inode, 1308 status = ocfs2_orphan_add(osb, handle, new_inode,
1298 newfe, orphan_name, 1309 newfe_bh, orphan_name,
1299 &orphan_insert, orphan_dir); 1310 &orphan_insert, orphan_dir);
1300 if (status < 0) { 1311 if (status < 0) {
1301 mlog_errno(status); 1312 mlog_errno(status);
@@ -1760,22 +1771,27 @@ static int ocfs2_symlink(struct inode *dir,
1760 } 1771 }
1761 } 1772 }
1762 1773
1763 status = ocfs2_add_entry(handle, dentry, inode, 1774 /*
1764 le64_to_cpu(fe->i_blkno), parent_fe_bh, 1775 * Do this before adding the entry to the directory. We add
1765 &lookup); 1776 * also set d_op after success so that ->d_iput() will cleanup
1766 if (status < 0) { 1777 * the dentry lock even if ocfs2_add_entry() fails below.
1778 */
1779 status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
1780 if (status) {
1767 mlog_errno(status); 1781 mlog_errno(status);
1768 goto bail; 1782 goto bail;
1769 } 1783 }
1784 dentry->d_op = &ocfs2_dentry_ops;
1770 1785
1771 status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); 1786 status = ocfs2_add_entry(handle, dentry, inode,
1772 if (status) { 1787 le64_to_cpu(fe->i_blkno), parent_fe_bh,
1788 &lookup);
1789 if (status < 0) {
1773 mlog_errno(status); 1790 mlog_errno(status);
1774 goto bail; 1791 goto bail;
1775 } 1792 }
1776 1793
1777 insert_inode_hash(inode); 1794 insert_inode_hash(inode);
1778 dentry->d_op = &ocfs2_dentry_ops;
1779 d_instantiate(dentry, inode); 1795 d_instantiate(dentry, inode);
1780bail: 1796bail:
1781 if (status < 0 && did_quota) 1797 if (status < 0 && did_quota)
@@ -1802,6 +1818,7 @@ bail:
1802 if (xattr_ac) 1818 if (xattr_ac)
1803 ocfs2_free_alloc_context(xattr_ac); 1819 ocfs2_free_alloc_context(xattr_ac);
1804 if ((status < 0) && inode) { 1820 if ((status < 0) && inode) {
1821 OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR;
1805 clear_nlink(inode); 1822 clear_nlink(inode);
1806 iput(inode); 1823 iput(inode);
1807 } 1824 }
@@ -1902,7 +1919,7 @@ leave:
1902static int ocfs2_orphan_add(struct ocfs2_super *osb, 1919static int ocfs2_orphan_add(struct ocfs2_super *osb,
1903 handle_t *handle, 1920 handle_t *handle,
1904 struct inode *inode, 1921 struct inode *inode,
1905 struct ocfs2_dinode *fe, 1922 struct buffer_head *fe_bh,
1906 char *name, 1923 char *name,
1907 struct ocfs2_dir_lookup_result *lookup, 1924 struct ocfs2_dir_lookup_result *lookup,
1908 struct inode *orphan_dir_inode) 1925 struct inode *orphan_dir_inode)
@@ -1910,6 +1927,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
1910 struct buffer_head *orphan_dir_bh = NULL; 1927 struct buffer_head *orphan_dir_bh = NULL;
1911 int status = 0; 1928 int status = 0;
1912 struct ocfs2_dinode *orphan_fe; 1929 struct ocfs2_dinode *orphan_fe;
1930 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
1913 1931
1914 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 1932 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
1915 1933
@@ -1945,13 +1963,31 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
1945 goto leave; 1963 goto leave;
1946 } 1964 }
1947 1965
1966 /*
1967 * We're going to journal the change of i_flags and i_orphaned_slot.
1968 * It's safe anyway, though some callers may duplicate the journaling.
1969 * Journaling within the func just make the logic look more
1970 * straightforward.
1971 */
1972 status = ocfs2_journal_access_di(handle,
1973 INODE_CACHE(inode),
1974 fe_bh,
1975 OCFS2_JOURNAL_ACCESS_WRITE);
1976 if (status < 0) {
1977 mlog_errno(status);
1978 goto leave;
1979 }
1980
1948 le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); 1981 le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL);
1982 OCFS2_I(inode)->ip_flags &= ~OCFS2_INODE_SKIP_ORPHAN_DIR;
1949 1983
1950 /* Record which orphan dir our inode now resides 1984 /* Record which orphan dir our inode now resides
1951 * in. delete_inode will use this to determine which orphan 1985 * in. delete_inode will use this to determine which orphan
1952 * dir to lock. */ 1986 * dir to lock. */
1953 fe->i_orphaned_slot = cpu_to_le16(osb->slot_num); 1987 fe->i_orphaned_slot = cpu_to_le16(osb->slot_num);
1954 1988
1989 ocfs2_journal_dirty(handle, fe_bh);
1990
1955 mlog(0, "Inode %llu orphaned in slot %d\n", 1991 mlog(0, "Inode %llu orphaned in slot %d\n",
1956 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); 1992 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
1957 1993
@@ -2104,7 +2140,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
2104 } 2140 }
2105 2141
2106 di = (struct ocfs2_dinode *)new_di_bh->b_data; 2142 di = (struct ocfs2_dinode *)new_di_bh->b_data;
2107 status = ocfs2_orphan_add(osb, handle, inode, di, orphan_name, 2143 status = ocfs2_orphan_add(osb, handle, inode, new_di_bh, orphan_name,
2108 &orphan_insert, orphan_dir); 2144 &orphan_insert, orphan_dir);
2109 if (status < 0) { 2145 if (status < 0) {
2110 mlog_errno(status); 2146 mlog_errno(status);
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index faaa4d072c9a..04ae76d8c6ab 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -3,6 +3,7 @@
3 */ 3 */
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/slab.h>
6#include <linux/quota.h> 7#include <linux/quota.h>
7#include <linux/quotaops.h> 8#include <linux/quotaops.h>
8#include <linux/dqblk_qtree.h> 9#include <linux/dqblk_qtree.h>
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index a8f4cea1b824..884b641f199e 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/slab.h>
6#include <linux/quota.h> 7#include <linux/quota.h>
7#include <linux/quotaops.h> 8#include <linux/quotaops.h>
8#include <linux/module.h> 9#include <linux/module.h>
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 52e4f6ee1e23..4793f36f6518 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -37,7 +37,6 @@
37 37
38#include <linux/bio.h> 38#include <linux/bio.h>
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/gfp.h>
41#include <linux/slab.h> 40#include <linux/slab.h>
42#include <linux/writeback.h> 41#include <linux/writeback.h>
43#include <linux/pagevec.h> 42#include <linux/pagevec.h>
@@ -4070,6 +4069,9 @@ static int ocfs2_complete_reflink(struct inode *s_inode,
4070 di->i_attr = s_di->i_attr; 4069 di->i_attr = s_di->i_attr;
4071 4070
4072 if (preserve) { 4071 if (preserve) {
4072 t_inode->i_uid = s_inode->i_uid;
4073 t_inode->i_gid = s_inode->i_gid;
4074 t_inode->i_mode = s_inode->i_mode;
4073 di->i_uid = s_di->i_uid; 4075 di->i_uid = s_di->i_uid;
4074 di->i_gid = s_di->i_gid; 4076 di->i_gid = s_di->i_gid;
4075 di->i_mode = s_di->i_mode; 4077 di->i_mode = s_di->i_mode;
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index 7020e1253ffa..0d3049f696c5 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/crc32.h> 21#include <linux/crc32.h>
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23 24
24/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */ 25/* Needed for AOP_TRUNCATED_PAGE in mlog_errno() */
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 5ae8812b2864..2dc57bca0688 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -21,6 +21,7 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/slab.h>
24#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
25#include <linux/reboot.h> 26#include <linux/reboot.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c
index 40e53702948c..bfe7190cdbf1 100644
--- a/fs/ocfs2/sysfile.c
+++ b/fs/ocfs2/sysfile.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/slab.h>
29#include <linux/highmem.h> 28#include <linux/highmem.h>
30 29
31#define MLOG_MASK_PREFIX ML_INODE 30#define MLOG_MASK_PREFIX ML_INODE