aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlmglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/dlmglue.c')
-rw-r--r--fs/ocfs2/dlmglue.c149
1 files changed, 113 insertions, 36 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 8801e41afe80..e335541727f9 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -49,6 +49,7 @@
49#include "dcache.h" 49#include "dcache.h"
50#include "dlmglue.h" 50#include "dlmglue.h"
51#include "extent_map.h" 51#include "extent_map.h"
52#include "file.h"
52#include "heartbeat.h" 53#include "heartbeat.h"
53#include "inode.h" 54#include "inode.h"
54#include "journal.h" 55#include "journal.h"
@@ -769,7 +770,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
769 int dlm_flags) 770 int dlm_flags)
770{ 771{
771 int ret = 0; 772 int ret = 0;
772 enum dlm_status status; 773 enum dlm_status status = DLM_NORMAL;
773 unsigned long flags; 774 unsigned long flags;
774 775
775 mlog_entry_void(); 776 mlog_entry_void();
@@ -1063,10 +1064,10 @@ static void ocfs2_cluster_unlock(struct ocfs2_super *osb,
1063 mlog_exit_void(); 1064 mlog_exit_void();
1064} 1065}
1065 1066
1066int ocfs2_create_new_lock(struct ocfs2_super *osb, 1067static int ocfs2_create_new_lock(struct ocfs2_super *osb,
1067 struct ocfs2_lock_res *lockres, 1068 struct ocfs2_lock_res *lockres,
1068 int ex, 1069 int ex,
1069 int local) 1070 int local)
1070{ 1071{
1071 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1072 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1072 unsigned long flags; 1073 unsigned long flags;
@@ -1137,6 +1138,7 @@ int ocfs2_rw_lock(struct inode *inode, int write)
1137{ 1138{
1138 int status, level; 1139 int status, level;
1139 struct ocfs2_lock_res *lockres; 1140 struct ocfs2_lock_res *lockres;
1141 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1140 1142
1141 BUG_ON(!inode); 1143 BUG_ON(!inode);
1142 1144
@@ -1146,6 +1148,9 @@ int ocfs2_rw_lock(struct inode *inode, int write)
1146 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1148 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1147 write ? "EXMODE" : "PRMODE"); 1149 write ? "EXMODE" : "PRMODE");
1148 1150
1151 if (ocfs2_mount_local(osb))
1152 return 0;
1153
1149 lockres = &OCFS2_I(inode)->ip_rw_lockres; 1154 lockres = &OCFS2_I(inode)->ip_rw_lockres;
1150 1155
1151 level = write ? LKM_EXMODE : LKM_PRMODE; 1156 level = write ? LKM_EXMODE : LKM_PRMODE;
@@ -1163,6 +1168,7 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
1163{ 1168{
1164 int level = write ? LKM_EXMODE : LKM_PRMODE; 1169 int level = write ? LKM_EXMODE : LKM_PRMODE;
1165 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; 1170 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres;
1171 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1166 1172
1167 mlog_entry_void(); 1173 mlog_entry_void();
1168 1174
@@ -1170,7 +1176,8 @@ void ocfs2_rw_unlock(struct inode *inode, int write)
1170 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1176 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1171 write ? "EXMODE" : "PRMODE"); 1177 write ? "EXMODE" : "PRMODE");
1172 1178
1173 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1179 if (!ocfs2_mount_local(osb))
1180 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1174 1181
1175 mlog_exit_void(); 1182 mlog_exit_void();
1176} 1183}
@@ -1181,6 +1188,7 @@ int ocfs2_data_lock_full(struct inode *inode,
1181{ 1188{
1182 int status = 0, level; 1189 int status = 0, level;
1183 struct ocfs2_lock_res *lockres; 1190 struct ocfs2_lock_res *lockres;
1191 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1184 1192
1185 BUG_ON(!inode); 1193 BUG_ON(!inode);
1186 1194
@@ -1200,6 +1208,9 @@ int ocfs2_data_lock_full(struct inode *inode,
1200 goto out; 1208 goto out;
1201 } 1209 }
1202 1210
1211 if (ocfs2_mount_local(osb))
1212 goto out;
1213
1203 lockres = &OCFS2_I(inode)->ip_data_lockres; 1214 lockres = &OCFS2_I(inode)->ip_data_lockres;
1204 1215
1205 level = write ? LKM_EXMODE : LKM_PRMODE; 1216 level = write ? LKM_EXMODE : LKM_PRMODE;
@@ -1268,6 +1279,7 @@ void ocfs2_data_unlock(struct inode *inode,
1268{ 1279{
1269 int level = write ? LKM_EXMODE : LKM_PRMODE; 1280 int level = write ? LKM_EXMODE : LKM_PRMODE;
1270 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; 1281 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres;
1282 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1271 1283
1272 mlog_entry_void(); 1284 mlog_entry_void();
1273 1285
@@ -1275,7 +1287,8 @@ void ocfs2_data_unlock(struct inode *inode,
1275 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1287 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1276 write ? "EXMODE" : "PRMODE"); 1288 write ? "EXMODE" : "PRMODE");
1277 1289
1278 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1290 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) &&
1291 !ocfs2_mount_local(osb))
1279 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1292 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1280 1293
1281 mlog_exit_void(); 1294 mlog_exit_void();
@@ -1466,8 +1479,9 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1466{ 1479{
1467 int status = 0; 1480 int status = 0;
1468 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1481 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1469 struct ocfs2_lock_res *lockres; 1482 struct ocfs2_lock_res *lockres = NULL;
1470 struct ocfs2_dinode *fe; 1483 struct ocfs2_dinode *fe;
1484 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1471 1485
1472 mlog_entry_void(); 1486 mlog_entry_void();
1473 1487
@@ -1482,10 +1496,12 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1482 } 1496 }
1483 spin_unlock(&oi->ip_lock); 1497 spin_unlock(&oi->ip_lock);
1484 1498
1485 lockres = &oi->ip_meta_lockres; 1499 if (!ocfs2_mount_local(osb)) {
1500 lockres = &oi->ip_meta_lockres;
1486 1501
1487 if (!ocfs2_should_refresh_lock_res(lockres)) 1502 if (!ocfs2_should_refresh_lock_res(lockres))
1488 goto bail; 1503 goto bail;
1504 }
1489 1505
1490 /* This will discard any caching information we might have had 1506 /* This will discard any caching information we might have had
1491 * for the inode metadata. */ 1507 * for the inode metadata. */
@@ -1495,7 +1511,7 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1495 * map (directories, bitmap files, etc) */ 1511 * map (directories, bitmap files, etc) */
1496 ocfs2_extent_map_trunc(inode, 0); 1512 ocfs2_extent_map_trunc(inode, 0);
1497 1513
1498 if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { 1514 if (lockres && ocfs2_meta_lvb_is_trustable(inode, lockres)) {
1499 mlog(0, "Trusting LVB on inode %llu\n", 1515 mlog(0, "Trusting LVB on inode %llu\n",
1500 (unsigned long long)oi->ip_blkno); 1516 (unsigned long long)oi->ip_blkno);
1501 ocfs2_refresh_inode_from_lvb(inode); 1517 ocfs2_refresh_inode_from_lvb(inode);
@@ -1542,7 +1558,8 @@ static int ocfs2_meta_lock_update(struct inode *inode,
1542 1558
1543 status = 0; 1559 status = 0;
1544bail_refresh: 1560bail_refresh:
1545 ocfs2_complete_lock_res_refresh(lockres, status); 1561 if (lockres)
1562 ocfs2_complete_lock_res_refresh(lockres, status);
1546bail: 1563bail:
1547 mlog_exit(status); 1564 mlog_exit(status);
1548 return status; 1565 return status;
@@ -1579,13 +1596,12 @@ static int ocfs2_assign_bh(struct inode *inode,
1579 * the result of the lock will be communicated via the callback. 1596 * the result of the lock will be communicated via the callback.
1580 */ 1597 */
1581int ocfs2_meta_lock_full(struct inode *inode, 1598int ocfs2_meta_lock_full(struct inode *inode,
1582 struct ocfs2_journal_handle *handle,
1583 struct buffer_head **ret_bh, 1599 struct buffer_head **ret_bh,
1584 int ex, 1600 int ex,
1585 int arg_flags) 1601 int arg_flags)
1586{ 1602{
1587 int status, level, dlm_flags, acquired; 1603 int status, level, dlm_flags, acquired;
1588 struct ocfs2_lock_res *lockres; 1604 struct ocfs2_lock_res *lockres = NULL;
1589 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 1605 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1590 struct buffer_head *local_bh = NULL; 1606 struct buffer_head *local_bh = NULL;
1591 1607
@@ -1607,6 +1623,9 @@ int ocfs2_meta_lock_full(struct inode *inode,
1607 goto bail; 1623 goto bail;
1608 } 1624 }
1609 1625
1626 if (ocfs2_mount_local(osb))
1627 goto local;
1628
1610 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) 1629 if (!(arg_flags & OCFS2_META_LOCK_RECOVERY))
1611 wait_event(osb->recovery_event, 1630 wait_event(osb->recovery_event,
1612 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1631 ocfs2_node_map_is_empty(osb, &osb->recovery_map));
@@ -1636,6 +1655,7 @@ int ocfs2_meta_lock_full(struct inode *inode,
1636 wait_event(osb->recovery_event, 1655 wait_event(osb->recovery_event,
1637 ocfs2_node_map_is_empty(osb, &osb->recovery_map)); 1656 ocfs2_node_map_is_empty(osb, &osb->recovery_map));
1638 1657
1658local:
1639 /* 1659 /*
1640 * We only see this flag if we're being called from 1660 * We only see this flag if we're being called from
1641 * ocfs2_read_locked_inode(). It means we're locking an inode 1661 * ocfs2_read_locked_inode(). It means we're locking an inode
@@ -1644,7 +1664,8 @@ int ocfs2_meta_lock_full(struct inode *inode,
1644 */ 1664 */
1645 if (inode->i_state & I_NEW) { 1665 if (inode->i_state & I_NEW) {
1646 status = 0; 1666 status = 0;
1647 ocfs2_complete_lock_res_refresh(lockres, 0); 1667 if (lockres)
1668 ocfs2_complete_lock_res_refresh(lockres, 0);
1648 goto bail; 1669 goto bail;
1649 } 1670 }
1650 1671
@@ -1668,12 +1689,6 @@ int ocfs2_meta_lock_full(struct inode *inode,
1668 } 1689 }
1669 } 1690 }
1670 1691
1671 if (handle) {
1672 status = ocfs2_handle_add_lock(handle, inode);
1673 if (status < 0)
1674 mlog_errno(status);
1675 }
1676
1677bail: 1692bail:
1678 if (status < 0) { 1693 if (status < 0) {
1679 if (ret_bh && (*ret_bh)) { 1694 if (ret_bh && (*ret_bh)) {
@@ -1713,18 +1728,16 @@ bail:
1713 * the lock inversion simply. 1728 * the lock inversion simply.
1714 */ 1729 */
1715int ocfs2_meta_lock_with_page(struct inode *inode, 1730int ocfs2_meta_lock_with_page(struct inode *inode,
1716 struct ocfs2_journal_handle *handle,
1717 struct buffer_head **ret_bh, 1731 struct buffer_head **ret_bh,
1718 int ex, 1732 int ex,
1719 struct page *page) 1733 struct page *page)
1720{ 1734{
1721 int ret; 1735 int ret;
1722 1736
1723 ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, 1737 ret = ocfs2_meta_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK);
1724 OCFS2_LOCK_NONBLOCK);
1725 if (ret == -EAGAIN) { 1738 if (ret == -EAGAIN) {
1726 unlock_page(page); 1739 unlock_page(page);
1727 if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) 1740 if (ocfs2_meta_lock(inode, ret_bh, ex) == 0)
1728 ocfs2_meta_unlock(inode, ex); 1741 ocfs2_meta_unlock(inode, ex);
1729 ret = AOP_TRUNCATED_PAGE; 1742 ret = AOP_TRUNCATED_PAGE;
1730 } 1743 }
@@ -1732,11 +1745,50 @@ int ocfs2_meta_lock_with_page(struct inode *inode,
1732 return ret; 1745 return ret;
1733} 1746}
1734 1747
1748int ocfs2_meta_lock_atime(struct inode *inode,
1749 struct vfsmount *vfsmnt,
1750 int *level)
1751{
1752 int ret;
1753
1754 mlog_entry_void();
1755 ret = ocfs2_meta_lock(inode, NULL, 0);
1756 if (ret < 0) {
1757 mlog_errno(ret);
1758 return ret;
1759 }
1760
1761 /*
1762 * If we should update atime, we will get EX lock,
1763 * otherwise we just get PR lock.
1764 */
1765 if (ocfs2_should_update_atime(inode, vfsmnt)) {
1766 struct buffer_head *bh = NULL;
1767
1768 ocfs2_meta_unlock(inode, 0);
1769 ret = ocfs2_meta_lock(inode, &bh, 1);
1770 if (ret < 0) {
1771 mlog_errno(ret);
1772 return ret;
1773 }
1774 *level = 1;
1775 if (ocfs2_should_update_atime(inode, vfsmnt))
1776 ocfs2_update_inode_atime(inode, bh);
1777 if (bh)
1778 brelse(bh);
1779 } else
1780 *level = 0;
1781
1782 mlog_exit(ret);
1783 return ret;
1784}
1785
1735void ocfs2_meta_unlock(struct inode *inode, 1786void ocfs2_meta_unlock(struct inode *inode,
1736 int ex) 1787 int ex)
1737{ 1788{
1738 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1789 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1739 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; 1790 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres;
1791 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1740 1792
1741 mlog_entry_void(); 1793 mlog_entry_void();
1742 1794
@@ -1744,7 +1796,8 @@ void ocfs2_meta_unlock(struct inode *inode,
1744 (unsigned long long)OCFS2_I(inode)->ip_blkno, 1796 (unsigned long long)OCFS2_I(inode)->ip_blkno,
1745 ex ? "EXMODE" : "PRMODE"); 1797 ex ? "EXMODE" : "PRMODE");
1746 1798
1747 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) 1799 if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) &&
1800 !ocfs2_mount_local(osb))
1748 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); 1801 ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
1749 1802
1750 mlog_exit_void(); 1803 mlog_exit_void();
@@ -1753,7 +1806,7 @@ void ocfs2_meta_unlock(struct inode *inode,
1753int ocfs2_super_lock(struct ocfs2_super *osb, 1806int ocfs2_super_lock(struct ocfs2_super *osb,
1754 int ex) 1807 int ex)
1755{ 1808{
1756 int status; 1809 int status = 0;
1757 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1810 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1758 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1811 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
1759 struct buffer_head *bh; 1812 struct buffer_head *bh;
@@ -1764,6 +1817,9 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
1764 if (ocfs2_is_hard_readonly(osb)) 1817 if (ocfs2_is_hard_readonly(osb))
1765 return -EROFS; 1818 return -EROFS;
1766 1819
1820 if (ocfs2_mount_local(osb))
1821 goto bail;
1822
1767 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); 1823 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
1768 if (status < 0) { 1824 if (status < 0) {
1769 mlog_errno(status); 1825 mlog_errno(status);
@@ -1802,7 +1858,8 @@ void ocfs2_super_unlock(struct ocfs2_super *osb,
1802 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1858 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1803 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; 1859 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
1804 1860
1805 ocfs2_cluster_unlock(osb, lockres, level); 1861 if (!ocfs2_mount_local(osb))
1862 ocfs2_cluster_unlock(osb, lockres, level);
1806} 1863}
1807 1864
1808int ocfs2_rename_lock(struct ocfs2_super *osb) 1865int ocfs2_rename_lock(struct ocfs2_super *osb)
@@ -1813,6 +1870,9 @@ int ocfs2_rename_lock(struct ocfs2_super *osb)
1813 if (ocfs2_is_hard_readonly(osb)) 1870 if (ocfs2_is_hard_readonly(osb))
1814 return -EROFS; 1871 return -EROFS;
1815 1872
1873 if (ocfs2_mount_local(osb))
1874 return 0;
1875
1816 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); 1876 status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0);
1817 if (status < 0) 1877 if (status < 0)
1818 mlog_errno(status); 1878 mlog_errno(status);
@@ -1824,7 +1884,8 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb)
1824{ 1884{
1825 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; 1885 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
1826 1886
1827 ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); 1887 if (!ocfs2_mount_local(osb))
1888 ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE);
1828} 1889}
1829 1890
1830int ocfs2_dentry_lock(struct dentry *dentry, int ex) 1891int ocfs2_dentry_lock(struct dentry *dentry, int ex)
@@ -1839,6 +1900,9 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex)
1839 if (ocfs2_is_hard_readonly(osb)) 1900 if (ocfs2_is_hard_readonly(osb))
1840 return -EROFS; 1901 return -EROFS;
1841 1902
1903 if (ocfs2_mount_local(osb))
1904 return 0;
1905
1842 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); 1906 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0);
1843 if (ret < 0) 1907 if (ret < 0)
1844 mlog_errno(ret); 1908 mlog_errno(ret);
@@ -1852,7 +1916,8 @@ void ocfs2_dentry_unlock(struct dentry *dentry, int ex)
1852 struct ocfs2_dentry_lock *dl = dentry->d_fsdata; 1916 struct ocfs2_dentry_lock *dl = dentry->d_fsdata;
1853 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); 1917 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
1854 1918
1855 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); 1919 if (!ocfs2_mount_local(osb))
1920 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level);
1856} 1921}
1857 1922
1858/* Reference counting of the dlm debug structure. We want this because 1923/* Reference counting of the dlm debug structure. We want this because
@@ -2115,12 +2180,15 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
2115 2180
2116int ocfs2_dlm_init(struct ocfs2_super *osb) 2181int ocfs2_dlm_init(struct ocfs2_super *osb)
2117{ 2182{
2118 int status; 2183 int status = 0;
2119 u32 dlm_key; 2184 u32 dlm_key;
2120 struct dlm_ctxt *dlm; 2185 struct dlm_ctxt *dlm = NULL;
2121 2186
2122 mlog_entry_void(); 2187 mlog_entry_void();
2123 2188
2189 if (ocfs2_mount_local(osb))
2190 goto local;
2191
2124 status = ocfs2_dlm_init_debug(osb); 2192 status = ocfs2_dlm_init_debug(osb);
2125 if (status < 0) { 2193 if (status < 0) {
2126 mlog_errno(status); 2194 mlog_errno(status);
@@ -2148,11 +2216,12 @@ int ocfs2_dlm_init(struct ocfs2_super *osb)
2148 goto bail; 2216 goto bail;
2149 } 2217 }
2150 2218
2219 dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb);
2220
2221local:
2151 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); 2222 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
2152 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); 2223 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
2153 2224
2154 dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb);
2155
2156 osb->dlm = dlm; 2225 osb->dlm = dlm;
2157 2226
2158 status = 0; 2227 status = 0;
@@ -2649,6 +2718,15 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2649 inode = ocfs2_lock_res_inode(lockres); 2718 inode = ocfs2_lock_res_inode(lockres);
2650 mapping = inode->i_mapping; 2719 mapping = inode->i_mapping;
2651 2720
2721 /*
2722 * We need this before the filemap_fdatawrite() so that it can
2723 * transfer the dirty bit from the PTE to the
2724 * page. Unfortunately this means that even for EX->PR
2725 * downconverts, we'll lose our mappings and have to build
2726 * them up again.
2727 */
2728 unmap_mapping_range(mapping, 0, 0, 0);
2729
2652 if (filemap_fdatawrite(mapping)) { 2730 if (filemap_fdatawrite(mapping)) {
2653 mlog(ML_ERROR, "Could not sync inode %llu for downconvert!", 2731 mlog(ML_ERROR, "Could not sync inode %llu for downconvert!",
2654 (unsigned long long)OCFS2_I(inode)->ip_blkno); 2732 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -2656,7 +2734,6 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2656 sync_mapping_buffers(mapping); 2734 sync_mapping_buffers(mapping);
2657 if (blocking == LKM_EXMODE) { 2735 if (blocking == LKM_EXMODE) {
2658 truncate_inode_pages(mapping, 0); 2736 truncate_inode_pages(mapping, 0);
2659 unmap_mapping_range(mapping, 0, 0, 0);
2660 } else { 2737 } else {
2661 /* We only need to wait on the I/O if we're not also 2738 /* We only need to wait on the I/O if we're not also
2662 * truncating pages because truncate_inode_pages waits 2739 * truncating pages because truncate_inode_pages waits