aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-06-08 14:04:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-06-08 14:04:06 -0400
commite72643088f576032d0d30c1d62c8fc077f383edc (patch)
tree5068dd46292b132f6178ced3b9124b27f549b907
parent32ba9c3fcab960f0b0d332c86ebcd2c4870d9bb8 (diff)
parent12027f1b3fd69a4e9017e6b13c72547a99c6cf54 (diff)
Merge tag 'upstream-3.5-rc2' of git://git.infradead.org/linux-ubifs
Pull UBI/UBIFS fixes from Artem Bityutskiy: "Fix UBI and UBIFS - they refuse to work without debugfs. This was broken by the 3.5-rc1 UBI/UBIFS changes when we removed the debugging Kconfig switches. Also, correct locking in 'ubi_wl_flush()' - it was extended to support flushing a specific LEB in 3.5-rc1, and the locking was sub-optimal." * tag 'upstream-3.5-rc2' of git://git.infradead.org/linux-ubifs: UBI: correct ubi_wl_flush locking UBIFS: fix debugfs-less systems support UBI: fix debugfs-less systems support
-rw-r--r--drivers/mtd/ubi/debug.c12
-rw-r--r--drivers/mtd/ubi/wl.c17
-rw-r--r--fs/ubifs/debug.c12
3 files changed, 33 insertions, 8 deletions
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 9f957c2d48e..09d4f8d9d59 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -264,6 +264,9 @@ static struct dentry *dfs_rootdir;
264 */ 264 */
265int ubi_debugfs_init(void) 265int ubi_debugfs_init(void)
266{ 266{
267 if (!IS_ENABLED(DEBUG_FS))
268 return 0;
269
267 dfs_rootdir = debugfs_create_dir("ubi", NULL); 270 dfs_rootdir = debugfs_create_dir("ubi", NULL);
268 if (IS_ERR_OR_NULL(dfs_rootdir)) { 271 if (IS_ERR_OR_NULL(dfs_rootdir)) {
269 int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir); 272 int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir);
@@ -281,7 +284,8 @@ int ubi_debugfs_init(void)
281 */ 284 */
282void ubi_debugfs_exit(void) 285void ubi_debugfs_exit(void)
283{ 286{
284 debugfs_remove(dfs_rootdir); 287 if (IS_ENABLED(DEBUG_FS))
288 debugfs_remove(dfs_rootdir);
285} 289}
286 290
287/* Read an UBI debugfs file */ 291/* Read an UBI debugfs file */
@@ -403,6 +407,9 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
403 struct dentry *dent; 407 struct dentry *dent;
404 struct ubi_debug_info *d = ubi->dbg; 408 struct ubi_debug_info *d = ubi->dbg;
405 409
410 if (!IS_ENABLED(DEBUG_FS))
411 return 0;
412
406 n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME, 413 n = snprintf(d->dfs_dir_name, UBI_DFS_DIR_LEN + 1, UBI_DFS_DIR_NAME,
407 ubi->ubi_num); 414 ubi->ubi_num);
408 if (n == UBI_DFS_DIR_LEN) { 415 if (n == UBI_DFS_DIR_LEN) {
@@ -470,5 +477,6 @@ out:
470 */ 477 */
471void ubi_debugfs_exit_dev(struct ubi_device *ubi) 478void ubi_debugfs_exit_dev(struct ubi_device *ubi)
472{ 479{
473 debugfs_remove_recursive(ubi->dbg->dfs_dir); 480 if (IS_ENABLED(DEBUG_FS))
481 debugfs_remove_recursive(ubi->dbg->dfs_dir);
474} 482}
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 9df100a4ec3..b6be644e7b8 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1262,11 +1262,11 @@ int ubi_wl_flush(struct ubi_device *ubi, int vol_id, int lnum)
1262 dbg_wl("flush pending work for LEB %d:%d (%d pending works)", 1262 dbg_wl("flush pending work for LEB %d:%d (%d pending works)",
1263 vol_id, lnum, ubi->works_count); 1263 vol_id, lnum, ubi->works_count);
1264 1264
1265 down_write(&ubi->work_sem);
1266 while (found) { 1265 while (found) {
1267 struct ubi_work *wrk; 1266 struct ubi_work *wrk;
1268 found = 0; 1267 found = 0;
1269 1268
1269 down_read(&ubi->work_sem);
1270 spin_lock(&ubi->wl_lock); 1270 spin_lock(&ubi->wl_lock);
1271 list_for_each_entry(wrk, &ubi->works, list) { 1271 list_for_each_entry(wrk, &ubi->works, list) {
1272 if ((vol_id == UBI_ALL || wrk->vol_id == vol_id) && 1272 if ((vol_id == UBI_ALL || wrk->vol_id == vol_id) &&
@@ -1277,18 +1277,27 @@ int ubi_wl_flush(struct ubi_device *ubi, int vol_id, int lnum)
1277 spin_unlock(&ubi->wl_lock); 1277 spin_unlock(&ubi->wl_lock);
1278 1278
1279 err = wrk->func(ubi, wrk, 0); 1279 err = wrk->func(ubi, wrk, 0);
1280 if (err) 1280 if (err) {
1281 goto out; 1281 up_read(&ubi->work_sem);
1282 return err;
1283 }
1284
1282 spin_lock(&ubi->wl_lock); 1285 spin_lock(&ubi->wl_lock);
1283 found = 1; 1286 found = 1;
1284 break; 1287 break;
1285 } 1288 }
1286 } 1289 }
1287 spin_unlock(&ubi->wl_lock); 1290 spin_unlock(&ubi->wl_lock);
1291 up_read(&ubi->work_sem);
1288 } 1292 }
1289 1293
1290out: 1294 /*
1295 * Make sure all the works which have been done in parallel are
1296 * finished.
1297 */
1298 down_write(&ubi->work_sem);
1291 up_write(&ubi->work_sem); 1299 up_write(&ubi->work_sem);
1300
1292 return err; 1301 return err;
1293} 1302}
1294 1303
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 685a83756b2..84a7e6f3c04 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2918,6 +2918,9 @@ int dbg_debugfs_init_fs(struct ubifs_info *c)
2918 struct dentry *dent; 2918 struct dentry *dent;
2919 struct ubifs_debug_info *d = c->dbg; 2919 struct ubifs_debug_info *d = c->dbg;
2920 2920
2921 if (!IS_ENABLED(DEBUG_FS))
2922 return 0;
2923
2921 n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME, 2924 n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
2922 c->vi.ubi_num, c->vi.vol_id); 2925 c->vi.ubi_num, c->vi.vol_id);
2923 if (n == UBIFS_DFS_DIR_LEN) { 2926 if (n == UBIFS_DFS_DIR_LEN) {
@@ -3010,7 +3013,8 @@ out:
3010 */ 3013 */
3011void dbg_debugfs_exit_fs(struct ubifs_info *c) 3014void dbg_debugfs_exit_fs(struct ubifs_info *c)
3012{ 3015{
3013 debugfs_remove_recursive(c->dbg->dfs_dir); 3016 if (IS_ENABLED(DEBUG_FS))
3017 debugfs_remove_recursive(c->dbg->dfs_dir);
3014} 3018}
3015 3019
3016struct ubifs_global_debug_info ubifs_dbg; 3020struct ubifs_global_debug_info ubifs_dbg;
@@ -3095,6 +3099,9 @@ int dbg_debugfs_init(void)
3095 const char *fname; 3099 const char *fname;
3096 struct dentry *dent; 3100 struct dentry *dent;
3097 3101
3102 if (!IS_ENABLED(DEBUG_FS))
3103 return 0;
3104
3098 fname = "ubifs"; 3105 fname = "ubifs";
3099 dent = debugfs_create_dir(fname, NULL); 3106 dent = debugfs_create_dir(fname, NULL);
3100 if (IS_ERR_OR_NULL(dent)) 3107 if (IS_ERR_OR_NULL(dent))
@@ -3159,7 +3166,8 @@ out:
3159 */ 3166 */
3160void dbg_debugfs_exit(void) 3167void dbg_debugfs_exit(void)
3161{ 3168{
3162 debugfs_remove_recursive(dfs_rootdir); 3169 if (IS_ENABLED(DEBUG_FS))
3170 debugfs_remove_recursive(dfs_rootdir);
3163} 3171}
3164 3172
3165/** 3173/**