aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorSunil Mushran <sunil.mushran@oracle.com>2009-06-22 14:40:07 -0400
committerJoel Becker <joel.becker@oracle.com>2009-06-22 17:24:55 -0400
commitdf152c241df9e9d2b9a65d37bd02961abe7f591a (patch)
tree47e0c71919ed437db33530a200113a562b9c6b89 /fs/ocfs2
parent3211949f8998dde71d9fe2e063de045ece5e0473 (diff)
ocfs2: Disable orphan scanning for local and hard-ro mounts
Local and Hard-RO mounts do not need orphan scanning. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dlmglue.c26
-rw-r--r--fs/ocfs2/dlmglue.h4
-rw-r--r--fs/ocfs2/journal.c30
-rw-r--r--fs/ocfs2/journal.h2
-rw-r--r--fs/ocfs2/super.c32
5 files changed, 51 insertions, 43 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index d3d1f9372f7e..1841bbb49cb6 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2366,15 +2366,20 @@ void ocfs2_inode_unlock(struct inode *inode,
2366 mlog_exit_void(); 2366 mlog_exit_void();
2367} 2367}
2368 2368
2369int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno, int ex) 2369int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno)
2370{ 2370{
2371 struct ocfs2_lock_res *lockres; 2371 struct ocfs2_lock_res *lockres;
2372 struct ocfs2_orphan_scan_lvb *lvb; 2372 struct ocfs2_orphan_scan_lvb *lvb;
2373 int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
2374 int status = 0; 2373 int status = 0;
2375 2374
2375 if (ocfs2_is_hard_readonly(osb))
2376 return -EROFS;
2377
2378 if (ocfs2_mount_local(osb))
2379 return 0;
2380
2376 lockres = &osb->osb_orphan_scan.os_lockres; 2381 lockres = &osb->osb_orphan_scan.os_lockres;
2377 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); 2382 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2378 if (status < 0) 2383 if (status < 0)
2379 return status; 2384 return status;
2380 2385
@@ -2388,17 +2393,18 @@ int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno, int ex)
2388 return status; 2393 return status;
2389} 2394}
2390 2395
2391void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno, int ex) 2396void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno)
2392{ 2397{
2393 struct ocfs2_lock_res *lockres; 2398 struct ocfs2_lock_res *lockres;
2394 struct ocfs2_orphan_scan_lvb *lvb; 2399 struct ocfs2_orphan_scan_lvb *lvb;
2395 int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
2396 2400
2397 lockres = &osb->osb_orphan_scan.os_lockres; 2401 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) {
2398 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); 2402 lockres = &osb->osb_orphan_scan.os_lockres;
2399 lvb->lvb_version = OCFS2_ORPHAN_LVB_VERSION; 2403 lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
2400 lvb->lvb_os_seqno = cpu_to_be32(seqno); 2404 lvb->lvb_version = OCFS2_ORPHAN_LVB_VERSION;
2401 ocfs2_cluster_unlock(osb, lockres, level); 2405 lvb->lvb_os_seqno = cpu_to_be32(seqno);
2406 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2407 }
2402} 2408}
2403 2409
2404int ocfs2_super_lock(struct ocfs2_super *osb, 2410int ocfs2_super_lock(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index 31b90d7b8f51..30f683107f1e 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -121,8 +121,8 @@ int ocfs2_super_lock(struct ocfs2_super *osb,
121 int ex); 121 int ex);
122void ocfs2_super_unlock(struct ocfs2_super *osb, 122void ocfs2_super_unlock(struct ocfs2_super *osb,
123 int ex); 123 int ex);
124int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno, int ex); 124int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno);
125void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno, int ex); 125void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno);
126 126
127int ocfs2_rename_lock(struct ocfs2_super *osb); 127int ocfs2_rename_lock(struct ocfs2_super *osb);
128void ocfs2_rename_unlock(struct ocfs2_super *osb); 128void ocfs2_rename_unlock(struct ocfs2_super *osb);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 0b2c27a9485e..f033760ecbea 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1883,7 +1883,7 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb)
1883 if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE) 1883 if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE)
1884 goto out; 1884 goto out;
1885 1885
1886 status = ocfs2_orphan_scan_lock(osb, &seqno, DLM_LOCK_EX); 1886 status = ocfs2_orphan_scan_lock(osb, &seqno);
1887 if (status < 0) { 1887 if (status < 0) {
1888 if (status != -EAGAIN) 1888 if (status != -EAGAIN)
1889 mlog_errno(status); 1889 mlog_errno(status);
@@ -1910,7 +1910,7 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb)
1910 os->os_count++; 1910 os->os_count++;
1911 os->os_scantime = CURRENT_TIME; 1911 os->os_scantime = CURRENT_TIME;
1912unlock: 1912unlock:
1913 ocfs2_orphan_scan_unlock(osb, seqno, DLM_LOCK_EX); 1913 ocfs2_orphan_scan_unlock(osb, seqno);
1914out: 1914out:
1915 return; 1915 return;
1916} 1916}
@@ -1938,29 +1938,33 @@ void ocfs2_orphan_scan_stop(struct ocfs2_super *osb)
1938 struct ocfs2_orphan_scan *os; 1938 struct ocfs2_orphan_scan *os;
1939 1939
1940 os = &osb->osb_orphan_scan; 1940 os = &osb->osb_orphan_scan;
1941 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE); 1941 if (atomic_read(&os->os_state) == ORPHAN_SCAN_ACTIVE) {
1942 mutex_lock(&os->os_lock); 1942 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1943 cancel_delayed_work(&os->os_orphan_scan_work); 1943 mutex_lock(&os->os_lock);
1944 mutex_unlock(&os->os_lock); 1944 cancel_delayed_work(&os->os_orphan_scan_work);
1945 mutex_unlock(&os->os_lock);
1946 }
1945} 1947}
1946 1948
1947int ocfs2_orphan_scan_init(struct ocfs2_super *osb) 1949void ocfs2_orphan_scan_init(struct ocfs2_super *osb)
1948{ 1950{
1949 struct ocfs2_orphan_scan *os; 1951 struct ocfs2_orphan_scan *os;
1950 1952
1951 os = &osb->osb_orphan_scan; 1953 os = &osb->osb_orphan_scan;
1952 atomic_set(&os->os_state, ORPHAN_SCAN_ACTIVE);
1953 os->os_osb = osb; 1954 os->os_osb = osb;
1954 os->os_count = 0; 1955 os->os_count = 0;
1955 os->os_seqno = 0; 1956 os->os_seqno = 0;
1956 os->os_scantime = CURRENT_TIME; 1957 os->os_scantime = CURRENT_TIME;
1957 mutex_init(&os->os_lock); 1958 mutex_init(&os->os_lock);
1959 INIT_DELAYED_WORK(&os->os_orphan_scan_work, ocfs2_orphan_scan_work);
1958 1960
1959 INIT_DELAYED_WORK(&os->os_orphan_scan_work, 1961 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
1960 ocfs2_orphan_scan_work); 1962 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1961 schedule_delayed_work(&os->os_orphan_scan_work, 1963 else {
1962 ocfs2_orphan_scan_timeout()); 1964 atomic_set(&os->os_state, ORPHAN_SCAN_ACTIVE);
1963 return 0; 1965 schedule_delayed_work(&os->os_orphan_scan_work,
1966 ocfs2_orphan_scan_timeout());
1967 }
1964} 1968}
1965 1969
1966struct ocfs2_orphan_filldir_priv { 1970struct ocfs2_orphan_filldir_priv {
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 61045eeb3f6e..5432c7f79cc6 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -144,7 +144,7 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
144} 144}
145 145
146/* Exported only for the journal struct init code in super.c. Do not call. */ 146/* Exported only for the journal struct init code in super.c. Do not call. */
147int ocfs2_orphan_scan_init(struct ocfs2_super *osb); 147void ocfs2_orphan_scan_init(struct ocfs2_super *osb);
148void ocfs2_orphan_scan_stop(struct ocfs2_super *osb); 148void ocfs2_orphan_scan_stop(struct ocfs2_super *osb);
149void ocfs2_orphan_scan_exit(struct ocfs2_super *osb); 149void ocfs2_orphan_scan_exit(struct ocfs2_super *osb);
150 150
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 3e8a68b103ab..0746e1abdfc7 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -205,11 +205,10 @@ static const match_table_t tokens = {
205#ifdef CONFIG_DEBUG_FS 205#ifdef CONFIG_DEBUG_FS
206static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) 206static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
207{ 207{
208 int out = 0;
209 int i;
210 struct ocfs2_cluster_connection *cconn = osb->cconn; 208 struct ocfs2_cluster_connection *cconn = osb->cconn;
211 struct ocfs2_recovery_map *rm = osb->recovery_map; 209 struct ocfs2_recovery_map *rm = osb->recovery_map;
212 struct ocfs2_orphan_scan *os; 210 struct ocfs2_orphan_scan *os = &osb->osb_orphan_scan;
211 int i, out = 0;
213 212
214 out += snprintf(buf + out, len - out, 213 out += snprintf(buf + out, len - out,
215 "%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n", 214 "%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n",
@@ -305,6 +304,16 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
305 atomic_read(&osb->s_num_inodes_stolen)); 304 atomic_read(&osb->s_num_inodes_stolen));
306 spin_unlock(&osb->osb_lock); 305 spin_unlock(&osb->osb_lock);
307 306
307 out += snprintf(buf + out, len - out, "OrphanScan => ");
308 out += snprintf(buf + out, len - out, "Local: %u Global: %u ",
309 os->os_count, os->os_seqno);
310 out += snprintf(buf + out, len - out, " Last Scan: ");
311 if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE)
312 out += snprintf(buf + out, len - out, "Disabled\n");
313 else
314 out += snprintf(buf + out, len - out, "%lu seconds ago\n",
315 (get_seconds() - os->os_scantime.tv_sec));
316
308 out += snprintf(buf + out, len - out, "%10s => %3s %10s\n", 317 out += snprintf(buf + out, len - out, "%10s => %3s %10s\n",
309 "Slots", "Num", "RecoGen"); 318 "Slots", "Num", "RecoGen");
310 for (i = 0; i < osb->max_slots; ++i) { 319 for (i = 0; i < osb->max_slots; ++i) {
@@ -315,13 +324,6 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
315 i, osb->slot_recovery_generations[i]); 324 i, osb->slot_recovery_generations[i]);
316 } 325 }
317 326
318 os = &osb->osb_orphan_scan;
319 out += snprintf(buf + out, len - out, "Orphan Scan=> ");
320 out += snprintf(buf + out, len - out, "Local: %u Global: %u ",
321 os->os_count, os->os_seqno);
322 out += snprintf(buf + out, len - out, " Last Scan: %lu seconds ago\n",
323 (get_seconds() - os->os_scantime.tv_sec));
324
325 return out; 327 return out;
326} 328}
327 329
@@ -1179,6 +1181,9 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1179 atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS); 1181 atomic_set(&osb->vol_state, VOLUME_MOUNTED_QUOTAS);
1180 wake_up(&osb->osb_mount_event); 1182 wake_up(&osb->osb_mount_event);
1181 1183
1184 /* Start this when the mount is almost sure of being successful */
1185 ocfs2_orphan_scan_init(osb);
1186
1182 mlog_exit(status); 1187 mlog_exit(status);
1183 return status; 1188 return status;
1184 1189
@@ -1983,13 +1988,6 @@ static int ocfs2_initialize_super(struct super_block *sb,
1983 goto bail; 1988 goto bail;
1984 } 1989 }
1985 1990
1986 status = ocfs2_orphan_scan_init(osb);
1987 if (status) {
1988 mlog(ML_ERROR, "Unable to initialize delayed orphan scan\n");
1989 mlog_errno(status);
1990 goto bail;
1991 }
1992
1993 init_waitqueue_head(&osb->checkpoint_event); 1991 init_waitqueue_head(&osb->checkpoint_event);
1994 atomic_set(&osb->needs_checkpoint, 0); 1992 atomic_set(&osb->needs_checkpoint, 0);
1995 1993