ocfs2: bugfix for hard readonly mount
cover ocfs2: bugfix for hard readonly mount
Hi, All,
These four patches are all related to ocfs2 on hard readonly mount. patch 1 fix oops when umount ocfs2 on hard readonly device. Because ocfs2_dismount_volume() will call ocfs2_cluster_hangup() and then call ocfs2_stack_driver_put(), will hit BUG_ON(active_stack == NULL).
patch 2 fix oops when do ls or cat in ocfs2 on hard readonly device. Because ocfs2_open_lock() will call ocfs2_cluster_lock() and then call ocfs2_dlm_lock(), but active_stack is NULL.
patch 3 fix bug of http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322ocfs2_statfs, ocfs2_fiemap, ocfs2_get_acl, ocfs2_listxattr and ocfs2_xattr_get need ocfs2_inode_lock to get dinode buffer head, but on hard readonly mount, they did not get they expected, so lead to oops. ocfs2_init_security_and_acl and ocfs2_test_inode_bit also called ocfs2_inode_lock(inode, &bh, 0), but they are safe, because ocfs2_reflink and ocfs2_get_dentry check hard read only before them.
patch 4 fix problem of running ls on hard readonly mount can't get the right result.
Because ocfs2_dentry_lock() return -EROFS. It should return 0.
best regards,
Tiger
PATCH 1/4 ocfs2: No need to hangup cluster on hard readonly mount
As no cluster service in hard readonly mount, so skip hangup cluster, otherwise ocfs2_stack_driver_put will hit BUG_ON.
--- fs/ocfs2/super.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/ocfs2/super.c +2 -1
@@ -1973,7 +1973,8 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)* If we failed before we got a uuid_str yet, we can't stop * heartbeat. Otherwise, do it. */ -if (!mnt_err && !ocfs2_mount_local (osb) && osb->uuid_str) +if (!mnt_err && !ocfs2_mount_local (osb) && osb->uuid_str && + !ocfs2_is_hard_readonly (osb)) hangup_needed =1 ;if (osb->cconn)
Signature · 1 line
1.7.4.4
PATCH 2/4 ocfs2: Add hard readonly check in open lock
In reply to Tiger YangAs no dlm lock in hard readonly mount, so add hard readonly check in open lock, otherwise ocfs2_cluster_lock leads to oops.
--- fs/ocfs2/dlmglue.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
fs/ocfs2/dlmglue.c +7 -1
@@ -1692,7 +1692,7 @@ int ocfs2_open_lock(struct inode *inode)mlog (0 ,"inode %llu take PRMODE open lock\n" , (unsigned long long )OCFS2_I (inode)->ip_blkno); -if (ocfs2_mount_local (osb)) +if (ocfs2_is_hard_readonly (osb) ||ocfs2_mount_local (osb)) goto out; lockres = &OCFS2_I (inode)->ip_open_lockres;
@@ -1718,6 +1718,12 @@ int ocfs2_try_open_lock(struct inode *inode, int write) (unsigned long long )OCFS2_I (inode)->ip_blkno, write ? "EXMODE" : "PRMODE"); +if (ocfs2_is_hard_readonly (osb)) { +if (write) + status = -EROFS ; + goto out; + } +if (ocfs2_mount_local (osb)) goto out;
Signature · 1 line
1.7.4.4
PATCH 3/4 ocfs2: Get dinode buffer head on hard readonly mount
In reply to Tiger Yangocfs2_statfs, ocfs2_fiemap, ocfs2_get_acl, ocfs2_listxattr and ocfs2_xattr_get need ocfs2_inode_lock to get dinode buffer head even on hard readonly mount.
--- fs/ocfs2/dlmglue.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/dlmglue.c +2 -2
@@ -2304,7 +2304,7 @@ int ocfs2_inode_lock_full_nested(struct inode *inode,if (ocfs2_is_hard_readonly (osb)) {if (ex) status = -EROFS ; - goto bail; + goto getbh; }if (ocfs2_mount_local (osb))
@@ -2362,7 +2362,7 @@ local:mlog_errno (status); goto bail; } - +getbh:if (ret_bh) { status =ocfs2_assign_bh (inode, ret_bh, local_bh);if (status <0 ) {
Signature · 1 line
1.7.4.4
PATCH 4/4 ocfs2: Get readonly dentry lock on hard readonly mount
In reply to Tiger YangAs some readonly operations such as ls, cat are allowed to run on hard readonly mount, so change return value to 0 to allow them to get fake readonly dentry lock.
--- fs/ocfs2/dlmglue.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
fs/ocfs2/dlmglue.c +6 -3
@@ -2634,8 +2634,11 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex)BUG_ON (!dl); -if (ocfs2_is_hard_readonly (osb)) -return -EROFS ; +if (ocfs2_is_hard_readonly (osb)) { +if (ex) +return -EROFS ; +return 0 ; + }if (ocfs2_mount_local (osb))return 0 ;
@@ -2653,7 +2656,7 @@ void ocfs2_dentry_unlock(struct dentry *dentry, int ex)struct ocfs2_dentry_lock *dl = dentry->d_fsdata;struct ocfs2_super *osb =OCFS2_SB (dentry->d_sb); -if (!ocfs2_mount_local (osb)) +if (!ocfs2_is_hard_readonly (osb) && !ocfs2_mount_local (osb))ocfs2_cluster_unlock (osb, &dl->dl_lockres, level); }
Signature · 1 line
1.7.4.4
cover ocfs2: bugfix for hard readonly mount
In reply to Tiger YangQuoted 18 lines · Tiger Yang
These four patches are all related to ocfs2 on hard readonly mount. patch 1 fix oops when umount ocfs2 on hard readonly device. Because
ocfs2_dismount_volume()will callocfs2_cluster_hangup()and then callocfs2_stack_driver_put(), will hitBUG_ON(active_stack == NULL).patch 2 fix oops when do ls or cat in ocfs2 on hard readonly device. Because
ocfs2_open_lock()will callocfs2_cluster_lock()and then callocfs2_dlm_lock(), butactive_stackis NULL.patch 3 fix bug of http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322
ocfs2_statfs,ocfs2_fiemap,ocfs2_get_acl,ocfs2_listxattrandocfs2_xattr_getneedocfs2_inode_lockto get dinode buffer head, but on hard readonly mount, they did not get they expected, so lead to oops.ocfs2_init_security_and_aclandocfs2_test_inode_bitalso calledocfs2_inode_lock(inode, &bh, 0), but they are safe, becauseocfs2_reflinkandocfs2_get_dentrycheck hard read only before them.
Quoted 3 lines
patch 4 fix problem of running ls on hard readonly mount can't get the right result.
Becauseocfs2_dentry_lock()return-EROFS. It should return 0.
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback. losetup -rf.
Thanks
Sunil
cover ocfs2: bugfix for hard readonly mount
Quoted 23 lines · Sunil Mushran
Quoted 18 lines · Tiger Yang
These four patches are all related to ocfs2 on hard readonly mount. patch 1 fix oops when umount ocfs2 on hard readonly device. Because
ocfs2_dismount_volume()will callocfs2_cluster_hangup()and then callocfs2_stack_driver_put(), will hitBUG_ON(active_stack == NULL).patch 2 fix oops when do ls or cat in ocfs2 on hard readonly device. Because
ocfs2_open_lock()will callocfs2_cluster_lock()and then callocfs2_dlm_lock(), butactive_stackis NULL.patch 3 fix bug of http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322
ocfs2_statfs,ocfs2_fiemap,ocfs2_get_acl,ocfs2_listxattrandocfs2_xattr_getneedocfs2_inode_lockto get dinode buffer head, but on hard readonly mount, they did not get they expected, so lead to oops.ocfs2_init_security_and_aclandocfs2_test_inode_bitalso calledocfs2_inode_lock(inode, &bh, 0), but they are safe, becauseocfs2_reflinkandocfs2_get_dentrycheck hard read only before them.Quoted 3 lines
patch 4 fix problem of running ls on hard readonly mount can't get the right result.
Becauseocfs2_dentry_lock()return-EROFS. It should return 0.
Quoted 7 lines
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback. losetup -rf.
Sure,
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Tristan
Quoted 3 lines
Thanks
Sunil
cover ocfs2: bugfix for hard readonly mount
Quoted 9 lines · Tristan Ye
Quoted 7 lines · Sunil Mushran
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback. losetup -rf.
Quoted 4 lines
Sure,
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Thanks Tristan.
Tiger, I would suggest you roll up the patch into one. I see no reason for the breakup considering it fixes just one bug and is small enough.
cover ocfs2: bugfix for hard readonly mount
Quoted 13 lines · Sunil Mushran
Quoted 12 lines · Tristan Ye
Quoted 8 lines · Sunil Mushran
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback.
losetup -rf.Sure,
Quoted 7 lines
Quoted 2 lines
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Thanks Tristan.
Tiger, I would suggest you roll up the patch into one. I see no reason for the breakup considering it fixes just one bug and is small enough.
After running tests on block/loopback device, it shows that:
1. 'ls -lR /kernel/tree' dumps slightly different output:
6c6
< total 436
---
Quoted 1 line
total 428
37c37
< total 52
---
Quoted 1 line
total 44
394c394
< total 252
---
Quoted 1 line
total 228
1408c1408
< total 8
---
Quoted 1 line
total 4
1636c1636
< total 8
while the data is consistent anyway.
2. 'stat -f' also dumps a slightly different map:
4,5c4,5
< Blocks: Total: 176120528 Free: 170080504 Available: 170080504
< Inodes: Total: 22015066 Free: 21260063
---
Quoted 2 lines
Blocks: Total: 176120528 Free: 170088304 Available: 170088304
Inodes: Total: 22015066 Free: 21261038
3. Enabling quota on readonly fs caused kernel oops
4. Otherwise, everything is fine(xattr,reflink,..etc)
Testing script attached.
Tristan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: verify_readonly.sh
Type: application/x-sh
Size: 15228 bytes
Desc: not available
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20110602/b891e97d/attachment-0001.sh
cover ocfs2: bugfix for hard readonly mount
Tristan,
Please can you build a newer ocfs2-test rpm. The last one was built on 2009.
The stat -f discrepancy is probably due to localalloc. We shouldn't be reserving space for hard-ro mounts. So should be ok as long as the discrepancy can be accounted for.
# grep "LocalAlloc " /sys/kernel/debug/ocfs2/*/fs_state The last column * clustersize is the space reserved.
I have no clue what the "total" value comprises off. Can you look into that?
Sunil
Quoted 64 lines · Tristan Ye
Quoted 10 lines · Sunil Mushran
Quoted 9 lines · Tristan Ye
Quoted 8 lines · Sunil Mushran
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback.
losetup -rf.Quoted 8 lines
Quoted 4 lines
Sure,
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Thanks Tristan.
Tiger, I would suggest you roll up the patch into one. I see no reason for the breakup considering it fixes just one bug and is small enough.
After running tests on block/loopback device, it shows that:
1. 'ls -lR /kernel/tree' dumps slightly different output:
6c6
< total 436
---Quoted 1 line
total 428
37c37
< total 52
---Quoted 1 line
total 44
394c394
< total 252
---Quoted 1 line
total 228
1408c1408
< total 8
---Quoted 1 line
total 4
1636c1636
< total 8while the data is consistent anyway.
2. 'stat -f' also dumps a slightly different map:
4,5c4,5
< Blocks: Total: 176120528 Free: 170080504 Available: 170080504 < Inodes: Total: 22015066 Free: 21260063---
Quoted 2 lines
Blocks: Total: 176120528 Free: 170088304 Available: 170088304
Inodes: Total: 22015066 Free: 212610383. Enabling quota on readonly fs caused kernel oops
4. Otherwise, everything is
fine(xattr,reflink,..etc)Testing script attached.
Tristan.
cover ocfs2: bugfix for hard readonly mount
Quoted 4 lines · Sunil Mushran
Tristan,
Please can you build a newer ocfs2-test rpm. The last one was built on 2009.
atop el6 with UEK kernel?
Quoted 11 lines
The stat -f discrepancy is probably due to localalloc. We shouldn't be reserving
space for hard-ro mounts. So should be ok as long as the discrepancy can be accounted for.# grep "LocalAlloc " /sys/kernel/debug/ocfs2/*/fs_state The last column * clustersize is the space reserved.I have no clue what the "total" value comprises off. Can you look into that?
Sure
Quoted 70 lines
Sunil
Quoted 65 lines · Tristan Ye
Quoted 11 lines · Sunil Mushran
Quoted 10 lines · Tristan Ye
Quoted 9 lines · Sunil Mushran
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat,
stat -f. This calls for a test script. We should be able to use loopback.
losetup -rf.Quoted 8 lines
Quoted 4 lines
Sure,
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Thanks Tristan.
Tiger, I would suggest you roll up the patch into one. I see no reason for the breakup considering it fixes just one bug and is small enough.
After running tests on block/loopback device, it shows that:
1. 'ls -lR /kernel/tree' dumps slightly different output:
6c6
< total 436
---Quoted 1 line
total 428
37c37
< total 52
---Quoted 1 line
total 44
394c394
< total 252
---Quoted 1 line
total 228
1408c1408
< total 8
---Quoted 1 line
total 4
1636c1636
< total 8while the data is consistent anyway.
2. 'stat -f' also dumps a slightly different map:
4,5c4,5
< Blocks: Total: 176120528 Free: 170080504 Available: 170080504 < Inodes: Total: 22015066 Free: 21260063---
Quoted 2 lines
Blocks: Total: 176120528 Free: 170088304 Available: 170088304
Inodes: Total: 22015066 Free: 212610383. Enabling quota on readonly fs caused kernel oops
4. Otherwise, everything is
fine(xattr,reflink,..etc)Testing script attached.
Tristan.
cover ocfs2: bugfix for hard readonly mount
Quoted 6 lines · Tristan Ye
Quoted 4 lines · Sunil Mushran
Tristan,
Please can you build a newer ocfs2-test rpm. The last one was built on 2009.
atop el6 with UEK kernel?
It is userspace. So kernel should not matter. I guess both el5 and el6 would be nice.
cover ocfs2: bugfix for hard readonly mount
Quoted 10 lines · Sunil Mushran
Quoted 6 lines · Tristan Ye
Quoted 4 lines · Sunil Mushran
Tristan,
Please can you build a newer ocfs2-test rpm. The last one was built on 2009.
atop el6 with UEK kernel?
It is userspace. So kernel should not matter. I guess both el5 and el6 would be nice.
Yep,
But parts of its testcases were intentional for 1.6 ocfs2, and was
dependent on latest ocfs2-tools-devel, ok, it's also fine, still userspace stuff;-)
cover ocfs2: bugfix for hard readonly mount
In reply to Sunil MushranQuoted 23 lines · Sunil Mushran
Quoted 18 lines · Tiger Yang
These four patches are all related to ocfs2 on hard readonly mount. patch 1 fix oops when umount ocfs2 on hard readonly device. Because
ocfs2_dismount_volume()will callocfs2_cluster_hangup()and then callocfs2_stack_driver_put(), will hitBUG_ON(active_stack == NULL).patch 2 fix oops when do ls or cat in ocfs2 on hard readonly device. Because
ocfs2_open_lock()will callocfs2_cluster_lock()and then callocfs2_dlm_lock(), butactive_stackis NULL.patch 3 fix bug of http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322
ocfs2_statfs,ocfs2_fiemap,ocfs2_get_acl,ocfs2_listxattrandocfs2_xattr_getneedocfs2_inode_lockto get dinode buffer head, but on hard readonly mount, they did not get they expected, so lead to oops.ocfs2_init_security_and_aclandocfs2_test_inode_bitalso calledocfs2_inode_lock(inode, &bh, 0), but they are safe, becauseocfs2_reflinkandocfs2_get_dentrycheck hard read only before them.Quoted 3 lines
patch 4 fix problem of running ls on hard readonly mount can't get the right result.
Becauseocfs2_dentry_lock()return-EROFS. It should return 0.
Quoted 7 lines
Tiger, Thanks. Was this tested with all fs-features enabled? I am worried about quotas. If not, please test that.
Tristan, Please can you cross check these patches. Enable all features in a volume, make it readonly and do mount, ls -lR, umount, read, stat, stat -f. This calls for a test script. We should be able to use loopback. losetup -rf.
Sure,
I'm going to write a dedicated script for sanity check, including these generic fs syscalls.
Tristan
Quoted 3 lines
Thanks
Sunil