aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/journal.c')
-rw-r--r--fs/ocfs2/journal.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 4a3b9e6b31ad..f033760ecbea 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1880,13 +1880,20 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb)
1880 1880
1881 os = &osb->osb_orphan_scan; 1881 os = &osb->osb_orphan_scan;
1882 1882
1883 status = ocfs2_orphan_scan_lock(osb, &seqno, DLM_LOCK_EX); 1883 if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE)
1884 goto out;
1885
1886 status = ocfs2_orphan_scan_lock(osb, &seqno);
1884 if (status < 0) { 1887 if (status < 0) {
1885 if (status != -EAGAIN) 1888 if (status != -EAGAIN)
1886 mlog_errno(status); 1889 mlog_errno(status);
1887 goto out; 1890 goto out;
1888 } 1891 }
1889 1892
1893 /* Do no queue the tasks if the volume is being umounted */
1894 if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE)
1895 goto unlock;
1896
1890 if (os->os_seqno != seqno) { 1897 if (os->os_seqno != seqno) {
1891 os->os_seqno = seqno; 1898 os->os_seqno = seqno;
1892 goto unlock; 1899 goto unlock;
@@ -1903,7 +1910,7 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb)
1903 os->os_count++; 1910 os->os_count++;
1904 os->os_scantime = CURRENT_TIME; 1911 os->os_scantime = CURRENT_TIME;
1905unlock: 1912unlock:
1906 ocfs2_orphan_scan_unlock(osb, seqno, DLM_LOCK_EX); 1913 ocfs2_orphan_scan_unlock(osb, seqno);
1907out: 1914out:
1908 return; 1915 return;
1909} 1916}
@@ -1920,8 +1927,9 @@ void ocfs2_orphan_scan_work(struct work_struct *work)
1920 1927
1921 mutex_lock(&os->os_lock); 1928 mutex_lock(&os->os_lock);
1922 ocfs2_queue_orphan_scan(osb); 1929 ocfs2_queue_orphan_scan(osb);
1923 schedule_delayed_work(&os->os_orphan_scan_work, 1930 if (atomic_read(&os->os_state) == ORPHAN_SCAN_ACTIVE)
1924 ocfs2_orphan_scan_timeout()); 1931 schedule_delayed_work(&os->os_orphan_scan_work,
1932 ocfs2_orphan_scan_timeout());
1925 mutex_unlock(&os->os_lock); 1933 mutex_unlock(&os->os_lock);
1926} 1934}
1927 1935
@@ -1930,26 +1938,33 @@ void ocfs2_orphan_scan_stop(struct ocfs2_super *osb)
1930 struct ocfs2_orphan_scan *os; 1938 struct ocfs2_orphan_scan *os;
1931 1939
1932 os = &osb->osb_orphan_scan; 1940 os = &osb->osb_orphan_scan;
1933 mutex_lock(&os->os_lock); 1941 if (atomic_read(&os->os_state) == ORPHAN_SCAN_ACTIVE) {
1934 cancel_delayed_work(&os->os_orphan_scan_work); 1942 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1935 mutex_unlock(&os->os_lock); 1943 mutex_lock(&os->os_lock);
1944 cancel_delayed_work(&os->os_orphan_scan_work);
1945 mutex_unlock(&os->os_lock);
1946 }
1936} 1947}
1937 1948
1938int ocfs2_orphan_scan_init(struct ocfs2_super *osb) 1949void ocfs2_orphan_scan_init(struct ocfs2_super *osb)
1939{ 1950{
1940 struct ocfs2_orphan_scan *os; 1951 struct ocfs2_orphan_scan *os;
1941 1952
1942 os = &osb->osb_orphan_scan; 1953 os = &osb->osb_orphan_scan;
1943 os->os_osb = osb; 1954 os->os_osb = osb;
1944 os->os_count = 0; 1955 os->os_count = 0;
1956 os->os_seqno = 0;
1945 os->os_scantime = CURRENT_TIME; 1957 os->os_scantime = CURRENT_TIME;
1946 mutex_init(&os->os_lock); 1958 mutex_init(&os->os_lock);
1947 1959 INIT_DELAYED_WORK(&os->os_orphan_scan_work, ocfs2_orphan_scan_work);
1948 INIT_DELAYED_WORK(&os->os_orphan_scan_work, 1960
1949 ocfs2_orphan_scan_work); 1961 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
1950 schedule_delayed_work(&os->os_orphan_scan_work, 1962 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1951 ocfs2_orphan_scan_timeout()); 1963 else {
1952 return 0; 1964 atomic_set(&os->os_state, ORPHAN_SCAN_ACTIVE);
1965 schedule_delayed_work(&os->os_orphan_scan_work,
1966 ocfs2_orphan_scan_timeout());
1967 }
1953} 1968}
1954 1969
1955struct ocfs2_orphan_filldir_priv { 1970struct ocfs2_orphan_filldir_priv {