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.c60
1 files changed, 45 insertions, 15 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 8801e41afe80..69fba16efbd1 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"
@@ -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;
@@ -1579,7 +1580,6 @@ static int ocfs2_assign_bh(struct inode *inode,
1579 * the result of the lock will be communicated via the callback. 1580 * the result of the lock will be communicated via the callback.
1580 */ 1581 */
1581int ocfs2_meta_lock_full(struct inode *inode, 1582int ocfs2_meta_lock_full(struct inode *inode,
1582 struct ocfs2_journal_handle *handle,
1583 struct buffer_head **ret_bh, 1583 struct buffer_head **ret_bh,
1584 int ex, 1584 int ex,
1585 int arg_flags) 1585 int arg_flags)
@@ -1668,12 +1668,6 @@ int ocfs2_meta_lock_full(struct inode *inode,
1668 } 1668 }
1669 } 1669 }
1670 1670
1671 if (handle) {
1672 status = ocfs2_handle_add_lock(handle, inode);
1673 if (status < 0)
1674 mlog_errno(status);
1675 }
1676
1677bail: 1671bail:
1678 if (status < 0) { 1672 if (status < 0) {
1679 if (ret_bh && (*ret_bh)) { 1673 if (ret_bh && (*ret_bh)) {
@@ -1713,18 +1707,16 @@ bail:
1713 * the lock inversion simply. 1707 * the lock inversion simply.
1714 */ 1708 */
1715int ocfs2_meta_lock_with_page(struct inode *inode, 1709int ocfs2_meta_lock_with_page(struct inode *inode,
1716 struct ocfs2_journal_handle *handle,
1717 struct buffer_head **ret_bh, 1710 struct buffer_head **ret_bh,
1718 int ex, 1711 int ex,
1719 struct page *page) 1712 struct page *page)
1720{ 1713{
1721 int ret; 1714 int ret;
1722 1715
1723 ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, 1716 ret = ocfs2_meta_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK);
1724 OCFS2_LOCK_NONBLOCK);
1725 if (ret == -EAGAIN) { 1717 if (ret == -EAGAIN) {
1726 unlock_page(page); 1718 unlock_page(page);
1727 if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) 1719 if (ocfs2_meta_lock(inode, ret_bh, ex) == 0)
1728 ocfs2_meta_unlock(inode, ex); 1720 ocfs2_meta_unlock(inode, ex);
1729 ret = AOP_TRUNCATED_PAGE; 1721 ret = AOP_TRUNCATED_PAGE;
1730 } 1722 }
@@ -1732,6 +1724,44 @@ int ocfs2_meta_lock_with_page(struct inode *inode,
1732 return ret; 1724 return ret;
1733} 1725}
1734 1726
1727int ocfs2_meta_lock_atime(struct inode *inode,
1728 struct vfsmount *vfsmnt,
1729 int *level)
1730{
1731 int ret;
1732
1733 mlog_entry_void();
1734 ret = ocfs2_meta_lock(inode, NULL, 0);
1735 if (ret < 0) {
1736 mlog_errno(ret);
1737 return ret;
1738 }
1739
1740 /*
1741 * If we should update atime, we will get EX lock,
1742 * otherwise we just get PR lock.
1743 */
1744 if (ocfs2_should_update_atime(inode, vfsmnt)) {
1745 struct buffer_head *bh = NULL;
1746
1747 ocfs2_meta_unlock(inode, 0);
1748 ret = ocfs2_meta_lock(inode, &bh, 1);
1749 if (ret < 0) {
1750 mlog_errno(ret);
1751 return ret;
1752 }
1753 *level = 1;
1754 if (ocfs2_should_update_atime(inode, vfsmnt))
1755 ocfs2_update_inode_atime(inode, bh);
1756 if (bh)
1757 brelse(bh);
1758 } else
1759 *level = 0;
1760
1761 mlog_exit(ret);
1762 return ret;
1763}
1764
1735void ocfs2_meta_unlock(struct inode *inode, 1765void ocfs2_meta_unlock(struct inode *inode,
1736 int ex) 1766 int ex)
1737{ 1767{