Commit 03efed8a2a1b8e00164eb4720a82a7dd5e368a8e
Committed by
Joel Becker
1 parent
e12ca23d41
Exists in
master
and in
6 other branches
ocfs2: Bugfix for hard readonly mount
ocfs2 cannot currently mount a device that is readonly at the media ("hard readonly"). Fix the broken places. see detail: http://oss.oracle.com/bugzilla/show_bug.cgi?id=1322 [ Description edited -- Joel ] Signed-off-by: Tiger Yang <tiger.yang@oracle.com> Reviewed-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Joel Becker <jlbec@evilplan.org>
Showing 2 changed files with 17 additions and 7 deletions Side-by-side Diff
fs/ocfs2/dlmglue.c
... | ... | @@ -1692,7 +1692,7 @@ |
1692 | 1692 | mlog(0, "inode %llu take PRMODE open lock\n", |
1693 | 1693 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
1694 | 1694 | |
1695 | - if (ocfs2_mount_local(osb)) | |
1695 | + if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb)) | |
1696 | 1696 | goto out; |
1697 | 1697 | |
1698 | 1698 | lockres = &OCFS2_I(inode)->ip_open_lockres; |
... | ... | @@ -1718,6 +1718,12 @@ |
1718 | 1718 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
1719 | 1719 | write ? "EXMODE" : "PRMODE"); |
1720 | 1720 | |
1721 | + if (ocfs2_is_hard_readonly(osb)) { | |
1722 | + if (write) | |
1723 | + status = -EROFS; | |
1724 | + goto out; | |
1725 | + } | |
1726 | + | |
1721 | 1727 | if (ocfs2_mount_local(osb)) |
1722 | 1728 | goto out; |
1723 | 1729 | |
... | ... | @@ -2298,7 +2304,7 @@ |
2298 | 2304 | if (ocfs2_is_hard_readonly(osb)) { |
2299 | 2305 | if (ex) |
2300 | 2306 | status = -EROFS; |
2301 | - goto bail; | |
2307 | + goto getbh; | |
2302 | 2308 | } |
2303 | 2309 | |
2304 | 2310 | if (ocfs2_mount_local(osb)) |
... | ... | @@ -2356,7 +2362,7 @@ |
2356 | 2362 | mlog_errno(status); |
2357 | 2363 | goto bail; |
2358 | 2364 | } |
2359 | - | |
2365 | +getbh: | |
2360 | 2366 | if (ret_bh) { |
2361 | 2367 | status = ocfs2_assign_bh(inode, ret_bh, local_bh); |
2362 | 2368 | if (status < 0) { |
... | ... | @@ -2628,8 +2634,11 @@ |
2628 | 2634 | |
2629 | 2635 | BUG_ON(!dl); |
2630 | 2636 | |
2631 | - if (ocfs2_is_hard_readonly(osb)) | |
2632 | - return -EROFS; | |
2637 | + if (ocfs2_is_hard_readonly(osb)) { | |
2638 | + if (ex) | |
2639 | + return -EROFS; | |
2640 | + return 0; | |
2641 | + } | |
2633 | 2642 | |
2634 | 2643 | if (ocfs2_mount_local(osb)) |
2635 | 2644 | return 0; |
... | ... | @@ -2647,7 +2656,7 @@ |
2647 | 2656 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; |
2648 | 2657 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
2649 | 2658 | |
2650 | - if (!ocfs2_mount_local(osb)) | |
2659 | + if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) | |
2651 | 2660 | ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); |
2652 | 2661 | } |
2653 | 2662 |
fs/ocfs2/super.c
... | ... | @@ -1974,7 +1974,8 @@ |
1974 | 1974 | * If we failed before we got a uuid_str yet, we can't stop |
1975 | 1975 | * heartbeat. Otherwise, do it. |
1976 | 1976 | */ |
1977 | - if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str) | |
1977 | + if (!mnt_err && !ocfs2_mount_local(osb) && osb->uuid_str && | |
1978 | + !ocfs2_is_hard_readonly(osb)) | |
1978 | 1979 | hangup_needed = 1; |
1979 | 1980 | |
1980 | 1981 | if (osb->cconn) |