ocfs2: local mounts

This allows users to format an ocfs2 file system with a special flag,
OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT. When the file system sees this flag, it
will not use any cluster services, nor will it require a cluster
configuration, thus acting like a 'local' file system.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

authored by Sunil Mushran and committed by Mark Fasheh c271c5c2 c9976797

+193 -66
+59 -20
fs/ocfs2/dlmglue.c
··· 770 int dlm_flags) 771 { 772 int ret = 0; 773 - enum dlm_status status; 774 unsigned long flags; 775 776 mlog_entry_void(); ··· 1138 { 1139 int status, level; 1140 struct ocfs2_lock_res *lockres; 1141 1142 BUG_ON(!inode); 1143 ··· 1147 mlog(0, "inode %llu take %s RW lock\n", 1148 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1149 write ? "EXMODE" : "PRMODE"); 1150 1151 lockres = &OCFS2_I(inode)->ip_rw_lockres; 1152 ··· 1168 { 1169 int level = write ? LKM_EXMODE : LKM_PRMODE; 1170 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; 1171 1172 mlog_entry_void(); 1173 ··· 1176 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1177 write ? "EXMODE" : "PRMODE"); 1178 1179 - ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1180 1181 mlog_exit_void(); 1182 } ··· 1188 { 1189 int status = 0, level; 1190 struct ocfs2_lock_res *lockres; 1191 1192 BUG_ON(!inode); 1193 ··· 1207 } 1208 goto out; 1209 } 1210 1211 lockres = &OCFS2_I(inode)->ip_data_lockres; 1212 ··· 1279 { 1280 int level = write ? LKM_EXMODE : LKM_PRMODE; 1281 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; 1282 1283 mlog_entry_void(); 1284 ··· 1287 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1288 write ? "EXMODE" : "PRMODE"); 1289 1290 - if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1291 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1292 1293 mlog_exit_void(); ··· 1479 { 1480 int status = 0; 1481 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1482 - struct ocfs2_lock_res *lockres; 1483 struct ocfs2_dinode *fe; 1484 1485 mlog_entry_void(); 1486 ··· 1496 } 1497 spin_unlock(&oi->ip_lock); 1498 1499 - lockres = &oi->ip_meta_lockres; 1500 1501 - if (!ocfs2_should_refresh_lock_res(lockres)) 1502 - goto bail; 1503 1504 /* This will discard any caching information we might have had 1505 * for the inode metadata. */ ··· 1511 * map (directories, bitmap files, etc) */ 1512 ocfs2_extent_map_trunc(inode, 0); 1513 1514 - if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { 1515 mlog(0, "Trusting LVB on inode %llu\n", 1516 (unsigned long long)oi->ip_blkno); 1517 ocfs2_refresh_inode_from_lvb(inode); ··· 1558 1559 status = 0; 1560 bail_refresh: 1561 - ocfs2_complete_lock_res_refresh(lockres, status); 1562 bail: 1563 mlog_exit(status); 1564 return status; ··· 1601 int arg_flags) 1602 { 1603 int status, level, dlm_flags, acquired; 1604 - struct ocfs2_lock_res *lockres; 1605 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1606 struct buffer_head *local_bh = NULL; 1607 ··· 1622 status = -EROFS; 1623 goto bail; 1624 } 1625 1626 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) 1627 wait_event(osb->recovery_event, ··· 1655 wait_event(osb->recovery_event, 1656 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1657 1658 /* 1659 * We only see this flag if we're being called from 1660 * ocfs2_read_locked_inode(). It means we're locking an inode ··· 1664 */ 1665 if (inode->i_state & I_NEW) { 1666 status = 0; 1667 - ocfs2_complete_lock_res_refresh(lockres, 0); 1668 goto bail; 1669 } 1670 ··· 1788 { 1789 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1790 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; 1791 1792 mlog_entry_void(); 1793 ··· 1796 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1797 ex ? "EXMODE" : "PRMODE"); 1798 1799 - if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1800 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1801 1802 mlog_exit_void(); ··· 1806 int ocfs2_super_lock(struct ocfs2_super *osb, 1807 int ex) 1808 { 1809 - int status; 1810 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1811 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1812 struct buffer_head *bh; ··· 1816 1817 if (ocfs2_is_hard_readonly(osb)) 1818 return -EROFS; 1819 1820 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); 1821 if (status < 0) { ··· 1858 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1859 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1860 1861 - ocfs2_cluster_unlock(osb, lockres, level); 1862 } 1863 1864 int ocfs2_rename_lock(struct ocfs2_super *osb) ··· 1869 1870 if (ocfs2_is_hard_readonly(osb)) 1871 return -EROFS; 1872 1873 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); 1874 if (status < 0) ··· 1884 { 1885 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; 1886 1887 - ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); 1888 } 1889 1890 int ocfs2_dentry_lock(struct dentry *dentry, int ex) ··· 1900 if (ocfs2_is_hard_readonly(osb)) 1901 return -EROFS; 1902 1903 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); 1904 if (ret < 0) 1905 mlog_errno(ret); ··· 1916 struct ocfs2_dentry_lock *dl = dentry->d_fsdata; 1917 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 1918 1919 - ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); 1920 } 1921 1922 /* Reference counting of the dlm debug structure. We want this because ··· 2180 2181 int ocfs2_dlm_init(struct ocfs2_super *osb) 2182 { 2183 - int status; 2184 u32 dlm_key; 2185 - struct dlm_ctxt *dlm; 2186 2187 mlog_entry_void(); 2188 2189 status = ocfs2_dlm_init_debug(osb); 2190 if (status < 0) { ··· 2216 goto bail; 2217 } 2218 2219 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); 2220 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); 2221 - 2222 - dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb); 2223 2224 osb->dlm = dlm; 2225
··· 770 int dlm_flags) 771 { 772 int ret = 0; 773 + enum dlm_status status = DLM_NORMAL; 774 unsigned long flags; 775 776 mlog_entry_void(); ··· 1138 { 1139 int status, level; 1140 struct ocfs2_lock_res *lockres; 1141 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1142 1143 BUG_ON(!inode); 1144 ··· 1146 mlog(0, "inode %llu take %s RW lock\n", 1147 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1148 write ? "EXMODE" : "PRMODE"); 1149 + 1150 + if (ocfs2_mount_local(osb)) 1151 + return 0; 1152 1153 lockres = &OCFS2_I(inode)->ip_rw_lockres; 1154 ··· 1164 { 1165 int level = write ? LKM_EXMODE : LKM_PRMODE; 1166 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; 1167 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1168 1169 mlog_entry_void(); 1170 ··· 1171 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1172 write ? "EXMODE" : "PRMODE"); 1173 1174 + if (!ocfs2_mount_local(osb)) 1175 + ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1176 1177 mlog_exit_void(); 1178 } ··· 1182 { 1183 int status = 0, level; 1184 struct ocfs2_lock_res *lockres; 1185 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1186 1187 BUG_ON(!inode); 1188 ··· 1200 } 1201 goto out; 1202 } 1203 + 1204 + if (ocfs2_mount_local(osb)) 1205 + goto out; 1206 1207 lockres = &OCFS2_I(inode)->ip_data_lockres; 1208 ··· 1269 { 1270 int level = write ? LKM_EXMODE : LKM_PRMODE; 1271 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; 1272 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1273 1274 mlog_entry_void(); 1275 ··· 1276 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1277 write ? "EXMODE" : "PRMODE"); 1278 1279 + if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && 1280 + !ocfs2_mount_local(osb)) 1281 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1282 1283 mlog_exit_void(); ··· 1467 { 1468 int status = 0; 1469 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1470 + struct ocfs2_lock_res *lockres = NULL; 1471 struct ocfs2_dinode *fe; 1472 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1473 1474 mlog_entry_void(); 1475 ··· 1483 } 1484 spin_unlock(&oi->ip_lock); 1485 1486 + if (!ocfs2_mount_local(osb)) { 1487 + lockres = &oi->ip_meta_lockres; 1488 1489 + if (!ocfs2_should_refresh_lock_res(lockres)) 1490 + goto bail; 1491 + } 1492 1493 /* This will discard any caching information we might have had 1494 * for the inode metadata. */ ··· 1496 * map (directories, bitmap files, etc) */ 1497 ocfs2_extent_map_trunc(inode, 0); 1498 1499 + if (lockres && ocfs2_meta_lvb_is_trustable(inode, lockres)) { 1500 mlog(0, "Trusting LVB on inode %llu\n", 1501 (unsigned long long)oi->ip_blkno); 1502 ocfs2_refresh_inode_from_lvb(inode); ··· 1543 1544 status = 0; 1545 bail_refresh: 1546 + if (lockres) 1547 + ocfs2_complete_lock_res_refresh(lockres, status); 1548 bail: 1549 mlog_exit(status); 1550 return status; ··· 1585 int arg_flags) 1586 { 1587 int status, level, dlm_flags, acquired; 1588 + struct ocfs2_lock_res *lockres = NULL; 1589 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1590 struct buffer_head *local_bh = NULL; 1591 ··· 1606 status = -EROFS; 1607 goto bail; 1608 } 1609 + 1610 + if (ocfs2_mount_local(osb)) 1611 + goto local; 1612 1613 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) 1614 wait_event(osb->recovery_event, ··· 1636 wait_event(osb->recovery_event, 1637 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1638 1639 + local: 1640 /* 1641 * We only see this flag if we're being called from 1642 * ocfs2_read_locked_inode(). It means we're locking an inode ··· 1644 */ 1645 if (inode->i_state & I_NEW) { 1646 status = 0; 1647 + if (lockres) 1648 + ocfs2_complete_lock_res_refresh(lockres, 0); 1649 goto bail; 1650 } 1651 ··· 1767 { 1768 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1769 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; 1770 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1771 1772 mlog_entry_void(); 1773 ··· 1774 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1775 ex ? "EXMODE" : "PRMODE"); 1776 1777 + if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && 1778 + !ocfs2_mount_local(osb)) 1779 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1780 1781 mlog_exit_void(); ··· 1783 int ocfs2_super_lock(struct ocfs2_super *osb, 1784 int ex) 1785 { 1786 + int status = 0; 1787 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1788 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1789 struct buffer_head *bh; ··· 1793 1794 if (ocfs2_is_hard_readonly(osb)) 1795 return -EROFS; 1796 + 1797 + if (ocfs2_mount_local(osb)) 1798 + goto bail; 1799 1800 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); 1801 if (status < 0) { ··· 1832 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1833 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1834 1835 + if (!ocfs2_mount_local(osb)) 1836 + ocfs2_cluster_unlock(osb, lockres, level); 1837 } 1838 1839 int ocfs2_rename_lock(struct ocfs2_super *osb) ··· 1842 1843 if (ocfs2_is_hard_readonly(osb)) 1844 return -EROFS; 1845 + 1846 + if (ocfs2_mount_local(osb)) 1847 + return 0; 1848 1849 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); 1850 if (status < 0) ··· 1854 { 1855 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; 1856 1857 + if (!ocfs2_mount_local(osb)) 1858 + ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); 1859 } 1860 1861 int ocfs2_dentry_lock(struct dentry *dentry, int ex) ··· 1869 if (ocfs2_is_hard_readonly(osb)) 1870 return -EROFS; 1871 1872 + if (ocfs2_mount_local(osb)) 1873 + return 0; 1874 + 1875 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); 1876 if (ret < 0) 1877 mlog_errno(ret); ··· 1882 struct ocfs2_dentry_lock *dl = dentry->d_fsdata; 1883 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 1884 1885 + if (!ocfs2_mount_local(osb)) 1886 + ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); 1887 } 1888 1889 /* Reference counting of the dlm debug structure. We want this because ··· 2145 2146 int ocfs2_dlm_init(struct ocfs2_super *osb) 2147 { 2148 + int status = 0; 2149 u32 dlm_key; 2150 + struct dlm_ctxt *dlm = NULL; 2151 2152 mlog_entry_void(); 2153 + 2154 + if (ocfs2_mount_local(osb)) 2155 + goto local; 2156 2157 status = ocfs2_dlm_init_debug(osb); 2158 if (status < 0) { ··· 2178 goto bail; 2179 } 2180 2181 + dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb); 2182 + 2183 + local: 2184 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); 2185 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); 2186 2187 osb->dlm = dlm; 2188
+9
fs/ocfs2/heartbeat.c
··· 154 { 155 int status; 156 157 status = o2hb_register_callback(&osb->osb_hb_down); 158 if (status < 0) { 159 mlog_errno(status); ··· 175 { 176 int status; 177 178 status = o2hb_unregister_callback(&osb->osb_hb_down); 179 if (status < 0) 180 mlog_errno(status); ··· 191 { 192 int ret; 193 char *argv[5], *envp[3]; 194 195 if (!osb->uuid_str) { 196 /* This can happen if we don't get far enough in mount... */
··· 154 { 155 int status; 156 157 + if (ocfs2_mount_local(osb)) 158 + return 0; 159 + 160 status = o2hb_register_callback(&osb->osb_hb_down); 161 if (status < 0) { 162 mlog_errno(status); ··· 172 { 173 int status; 174 175 + if (ocfs2_mount_local(osb)) 176 + return; 177 + 178 status = o2hb_unregister_callback(&osb->osb_hb_down); 179 if (status < 0) 180 mlog_errno(status); ··· 185 { 186 int ret; 187 char *argv[5], *envp[3]; 188 + 189 + if (ocfs2_mount_local(osb)) 190 + return; 191 192 if (!osb->uuid_str) { 193 /* This can happen if we don't get far enough in mount... */
+2 -1
fs/ocfs2/inode.c
··· 423 * cluster lock before trusting anything anyway. 424 */ 425 can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE) 426 - && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK); 427 428 /* 429 * To maintain backwards compatibility with older versions of
··· 423 * cluster lock before trusting anything anyway. 424 */ 425 can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE) 426 + && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK) 427 + && !ocfs2_mount_local(osb); 428 429 /* 430 * To maintain backwards compatibility with older versions of
+33 -13
fs/ocfs2/journal.c
··· 144 ocfs2_abort(osb->sb, "Detected aborted journal"); 145 handle = ERR_PTR(-EROFS); 146 } 147 - } else 148 - atomic_inc(&(osb->journal->j_num_trans)); 149 150 return handle; 151 } ··· 509 510 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); 511 512 - status = ocfs2_journal_toggle_dirty(osb, 0); 513 - if (status < 0) 514 - mlog_errno(status); 515 516 /* Shutdown the kernel journal system */ 517 journal_destroy(journal->j_journal); ··· 565 } 566 } 567 568 - int ocfs2_journal_load(struct ocfs2_journal *journal) 569 { 570 int status = 0; 571 struct ocfs2_super *osb; ··· 592 } 593 594 /* Launch the commit thread */ 595 - osb->commit_task = kthread_run(ocfs2_commit_thread, osb, "ocfs2cmt"); 596 - if (IS_ERR(osb->commit_task)) { 597 - status = PTR_ERR(osb->commit_task); 598 osb->commit_task = NULL; 599 - mlog(ML_ERROR, "unable to launch ocfs2commit thread, error=%d", 600 - status); 601 - goto done; 602 - } 603 604 done: 605 mlog_exit(status);
··· 144 ocfs2_abort(osb->sb, "Detected aborted journal"); 145 handle = ERR_PTR(-EROFS); 146 } 147 + } else { 148 + if (!ocfs2_mount_local(osb)) 149 + atomic_inc(&(osb->journal->j_num_trans)); 150 + } 151 152 return handle; 153 } ··· 507 508 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); 509 510 + if (ocfs2_mount_local(osb)) { 511 + journal_lock_updates(journal->j_journal); 512 + status = journal_flush(journal->j_journal); 513 + journal_unlock_updates(journal->j_journal); 514 + if (status < 0) 515 + mlog_errno(status); 516 + } 517 + 518 + if (status == 0) { 519 + /* 520 + * Do not toggle if flush was unsuccessful otherwise 521 + * will leave dirty metadata in a "clean" journal 522 + */ 523 + status = ocfs2_journal_toggle_dirty(osb, 0); 524 + if (status < 0) 525 + mlog_errno(status); 526 + } 527 528 /* Shutdown the kernel journal system */ 529 journal_destroy(journal->j_journal); ··· 549 } 550 } 551 552 + int ocfs2_journal_load(struct ocfs2_journal *journal, int local) 553 { 554 int status = 0; 555 struct ocfs2_super *osb; ··· 576 } 577 578 /* Launch the commit thread */ 579 + if (!local) { 580 + osb->commit_task = kthread_run(ocfs2_commit_thread, osb, 581 + "ocfs2cmt"); 582 + if (IS_ERR(osb->commit_task)) { 583 + status = PTR_ERR(osb->commit_task); 584 + osb->commit_task = NULL; 585 + mlog(ML_ERROR, "unable to launch ocfs2commit thread, " 586 + "error=%d", status); 587 + goto done; 588 + } 589 + } else 590 osb->commit_task = NULL; 591 592 done: 593 mlog_exit(status);
+4 -1
fs/ocfs2/journal.h
··· 157 void ocfs2_journal_shutdown(struct ocfs2_super *osb); 158 int ocfs2_journal_wipe(struct ocfs2_journal *journal, 159 int full); 160 - int ocfs2_journal_load(struct ocfs2_journal *journal); 161 int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); 162 void ocfs2_recovery_thread(struct ocfs2_super *osb, 163 int node_num); ··· 173 static inline void ocfs2_checkpoint_inode(struct inode *inode) 174 { 175 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 176 177 if (!ocfs2_inode_fully_checkpointed(inode)) { 178 /* WARNING: This only kicks off a single
··· 157 void ocfs2_journal_shutdown(struct ocfs2_super *osb); 158 int ocfs2_journal_wipe(struct ocfs2_journal *journal, 159 int full); 160 + int ocfs2_journal_load(struct ocfs2_journal *journal, int local); 161 int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); 162 void ocfs2_recovery_thread(struct ocfs2_super *osb, 163 int node_num); ··· 173 static inline void ocfs2_checkpoint_inode(struct inode *inode) 174 { 175 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 176 + 177 + if (ocfs2_mount_local(osb)) 178 + return; 179 180 if (!ocfs2_inode_fully_checkpointed(inode)) { 181 /* WARNING: This only kicks off a single
+4 -2
fs/ocfs2/mmap.c
··· 83 int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) 84 { 85 int ret = 0, lock_level = 0; 86 87 /* We don't want to support shared writable mappings yet. */ 88 - if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) 89 - && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { 90 mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); 91 /* This is -EINVAL because generic_file_readonly_mmap 92 * returns it in a similar situation. */
··· 83 int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) 84 { 85 int ret = 0, lock_level = 0; 86 + struct ocfs2_super *osb = OCFS2_SB(file->f_dentry->d_inode->i_sb); 87 88 /* We don't want to support shared writable mappings yet. */ 89 + if (!ocfs2_mount_local(osb) && 90 + ((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) && 91 + ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { 92 mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); 93 /* This is -EINVAL because generic_file_readonly_mmap 94 * returns it in a similar situation. */
+5 -3
fs/ocfs2/namei.c
··· 587 } 588 589 ocfs2_inode_set_new(osb, inode); 590 - status = ocfs2_create_new_inode_locks(inode); 591 - if (status < 0) 592 - mlog_errno(status); 593 594 status = 0; /* error in ocfs2_create_new_inode_locks is not 595 * critical */
··· 587 } 588 589 ocfs2_inode_set_new(osb, inode); 590 + if (!ocfs2_mount_local(osb)) { 591 + status = ocfs2_create_new_inode_locks(inode); 592 + if (status < 0) 593 + mlog_errno(status); 594 + } 595 596 status = 0; /* error in ocfs2_create_new_inode_locks is not 597 * critical */
+5
fs/ocfs2/ocfs2.h
··· 349 return ret; 350 } 351 352 #define OCFS2_IS_VALID_DINODE(ptr) \ 353 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) 354
··· 349 return ret; 350 } 351 352 + static inline int ocfs2_mount_local(struct ocfs2_super *osb) 353 + { 354 + return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT); 355 + } 356 + 357 #define OCFS2_IS_VALID_DINODE(ptr) \ 358 (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) 359
+4 -1
fs/ocfs2/ocfs2_fs.h
··· 86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask) 87 88 #define OCFS2_FEATURE_COMPAT_SUPP 0 89 - #define OCFS2_FEATURE_INCOMPAT_SUPP 0 90 #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 91 92 /* ··· 96 */ 97 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 98 99 100 /* 101 * Flags on ocfs2_dinode.i_flags
··· 86 OCFS2_SB(sb)->s_feature_incompat &= ~(mask) 87 88 #define OCFS2_FEATURE_COMPAT_SUPP 0 89 + #define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 90 #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 91 92 /* ··· 96 */ 97 #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 98 99 + 100 + /* Used to denote a non-clustered volume */ 101 + #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008 102 103 /* 104 * Flags on ocfs2_dinode.i_flags
+65 -25
fs/ocfs2/super.c
··· 508 return status; 509 } 510 511 static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) 512 { 513 struct dentry *root; ··· 537 struct inode *inode = NULL; 538 struct ocfs2_super *osb = NULL; 539 struct buffer_head *bh = NULL; 540 541 mlog_entry("%p, %p, %i", sb, data, silent); 542 543 - /* for now we only have one cluster/node, make sure we see it 544 - * in the heartbeat universe */ 545 - if (!o2hb_check_local_node_heartbeating()) { 546 status = -EINVAL; 547 goto read_super_error; 548 } 549 550 /* probe for superblock */ ··· 570 } 571 brelse(bh); 572 bh = NULL; 573 - 574 - if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { 575 - status = -EINVAL; 576 - goto read_super_error; 577 - } 578 osb->s_mount_opt = parsed_opt; 579 580 sb->s_magic = OCFS2_SUPER_MAGIC; ··· 612 } 613 614 if (!ocfs2_is_hard_readonly(osb)) { 615 - /* If this isn't a hard readonly mount, then we need 616 - * to make sure that heartbeat is in a valid state, 617 - * and that we mark ourselves soft readonly is -oro 618 - * was specified. */ 619 - if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { 620 - mlog(ML_ERROR, "No heartbeat for device (%s)\n", 621 - sb->s_id); 622 - status = -EINVAL; 623 - goto read_super_error; 624 - } 625 - 626 if (sb->s_flags & MS_RDONLY) 627 ocfs2_set_ro_flag(osb, 0); 628 } 629 630 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, ··· 654 655 ocfs2_complete_mount_recovery(osb); 656 657 - printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %d, slot %d) " 658 "with %s data mode.\n", 659 - osb->dev_str, osb->node_num, osb->slot_num, 660 osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : 661 "ordered"); 662 ··· 1023 1024 /* XXX hold a ref on the node while mounte? easy enough, if 1025 * desirable. */ 1026 - osb->node_num = o2nm_this_node(); 1027 if (osb->node_num == O2NM_MAX_NODES) { 1028 mlog(ML_ERROR, "could not find this host's node number\n"); 1029 status = -ENOENT; ··· 1112 goto leave; 1113 } 1114 1115 /* This should be sent *after* we recovered our journal as it 1116 * will cause other nodes to unmark us as needing 1117 * recovery. However, we need to send it *before* dropping the ··· 1145 { 1146 int tmp; 1147 struct ocfs2_super *osb = NULL; 1148 1149 mlog_entry("(0x%p)\n", sb); 1150 ··· 1209 1210 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); 1211 1212 - printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %d)\n", 1213 - osb->dev_str, osb->node_num); 1214 1215 ocfs2_delete_osb(osb); 1216 kfree(osb); ··· 1573 { 1574 int status = 0; 1575 int dirty; 1576 struct ocfs2_dinode *local_alloc = NULL; /* only used if we 1577 * recover 1578 * ourselves. */ ··· 1601 "recovering volume.\n"); 1602 } 1603 1604 /* will play back anything left in the journal. */ 1605 - ocfs2_journal_load(osb->journal); 1606 1607 if (dirty) { 1608 /* recover my local alloc if we didn't unmount cleanly. */
··· 508 return status; 509 } 510 511 + static int ocfs2_verify_heartbeat(struct ocfs2_super *osb) 512 + { 513 + if (ocfs2_mount_local(osb)) { 514 + if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { 515 + mlog(ML_ERROR, "Cannot heartbeat on a locally " 516 + "mounted device.\n"); 517 + return -EINVAL; 518 + } 519 + } 520 + 521 + if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { 522 + if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb)) { 523 + mlog(ML_ERROR, "Heartbeat has to be started to mount " 524 + "a read-write clustered device.\n"); 525 + return -EINVAL; 526 + } 527 + } 528 + 529 + return 0; 530 + } 531 + 532 static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) 533 { 534 struct dentry *root; ··· 516 struct inode *inode = NULL; 517 struct ocfs2_super *osb = NULL; 518 struct buffer_head *bh = NULL; 519 + char nodestr[8]; 520 521 mlog_entry("%p, %p, %i", sb, data, silent); 522 523 + if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { 524 status = -EINVAL; 525 goto read_super_error; 526 + } 527 + 528 + /* for now we only have one cluster/node, make sure we see it 529 + * in the heartbeat universe */ 530 + if (parsed_opt & OCFS2_MOUNT_HB_LOCAL) { 531 + if (!o2hb_check_local_node_heartbeating()) { 532 + status = -EINVAL; 533 + goto read_super_error; 534 + } 535 } 536 537 /* probe for superblock */ ··· 541 } 542 brelse(bh); 543 bh = NULL; 544 osb->s_mount_opt = parsed_opt; 545 546 sb->s_magic = OCFS2_SUPER_MAGIC; ··· 588 } 589 590 if (!ocfs2_is_hard_readonly(osb)) { 591 if (sb->s_flags & MS_RDONLY) 592 ocfs2_set_ro_flag(osb, 0); 593 + } 594 + 595 + status = ocfs2_verify_heartbeat(osb); 596 + if (status < 0) { 597 + mlog_errno(status); 598 + goto read_super_error; 599 } 600 601 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, ··· 635 636 ocfs2_complete_mount_recovery(osb); 637 638 + if (ocfs2_mount_local(osb)) 639 + snprintf(nodestr, sizeof(nodestr), "local"); 640 + else 641 + snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); 642 + 643 + printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " 644 "with %s data mode.\n", 645 + osb->dev_str, nodestr, osb->slot_num, 646 osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : 647 "ordered"); 648 ··· 999 1000 /* XXX hold a ref on the node while mounte? easy enough, if 1001 * desirable. */ 1002 + if (ocfs2_mount_local(osb)) 1003 + osb->node_num = 0; 1004 + else 1005 + osb->node_num = o2nm_this_node(); 1006 + 1007 if (osb->node_num == O2NM_MAX_NODES) { 1008 mlog(ML_ERROR, "could not find this host's node number\n"); 1009 status = -ENOENT; ··· 1084 goto leave; 1085 } 1086 1087 + if (ocfs2_mount_local(osb)) 1088 + goto leave; 1089 + 1090 /* This should be sent *after* we recovered our journal as it 1091 * will cause other nodes to unmark us as needing 1092 * recovery. However, we need to send it *before* dropping the ··· 1114 { 1115 int tmp; 1116 struct ocfs2_super *osb = NULL; 1117 + char nodestr[8]; 1118 1119 mlog_entry("(0x%p)\n", sb); 1120 ··· 1177 1178 atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); 1179 1180 + if (ocfs2_mount_local(osb)) 1181 + snprintf(nodestr, sizeof(nodestr), "local"); 1182 + else 1183 + snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); 1184 + 1185 + printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", 1186 + osb->dev_str, nodestr); 1187 1188 ocfs2_delete_osb(osb); 1189 kfree(osb); ··· 1536 { 1537 int status = 0; 1538 int dirty; 1539 + int local; 1540 struct ocfs2_dinode *local_alloc = NULL; /* only used if we 1541 * recover 1542 * ourselves. */ ··· 1563 "recovering volume.\n"); 1564 } 1565 1566 + local = ocfs2_mount_local(osb); 1567 + 1568 /* will play back anything left in the journal. */ 1569 + ocfs2_journal_load(osb->journal, local); 1570 1571 if (dirty) { 1572 /* recover my local alloc if we didn't unmount cleanly. */
+3
fs/ocfs2/vote.c
··· 1000 { 1001 int status = 0; 1002 1003 status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, 1004 osb->net_key, 1005 sizeof(struct ocfs2_response_msg),
··· 1000 { 1001 int status = 0; 1002 1003 + if (ocfs2_mount_local(osb)) 1004 + return 0; 1005 + 1006 status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, 1007 osb->net_key, 1008 sizeof(struct ocfs2_response_msg),