View | Details | Raw Unified | Return to bug 206153
Collapse All | Expand All

(-)a/fs/ubifs/file.c (+16 lines)
Lines 41-46 Link Here
41
#include <linux/mount.h>
41
#include <linux/mount.h>
42
#include <linux/slab.h>
42
#include <linux/slab.h>
43
#include <linux/migrate.h>
43
#include <linux/migrate.h>
44
#include <linux/delay.h>
44
45
45
static int read_block(struct inode *inode, void *addr, unsigned int block,
46
static int read_block(struct inode *inode, void *addr, unsigned int block,
46
		      struct ubifs_data_node *dn)
47
		      struct ubifs_data_node *dn)
Lines 372-378 static int allocate_budget(struct ubifs_info *c, struct page *page, Link Here
372
			req.dirtied_page = 1;
373
			req.dirtied_page = 1;
373
374
374
		if (appending) {
375
		if (appending) {
376
			printk("{WRITE_ITER} Step 2. Appending page %ps by allocate_budget, ino=%lu LOCK UI ==\n", page, page->mapping->host->i_ino);
375
			mutex_lock(&ui->ui_mutex);
377
			mutex_lock(&ui->ui_mutex);
378
			printk("{WRITE_ITER} Step 2. Appending page %ps by allocate_budget, ino=%lu LOCK UI --\n", page, page->mapping->host->i_ino);
376
			if (!ui->dirty)
379
			if (!ui->dirty)
377
				/*
380
				/*
378
				 * The inode is clean but we will have to mark
381
				 * The inode is clean but we will have to mark
Lines 436-446 static int ubifs_write_begin(struct file *file, struct address_space *mapping, Link Here
436
	if (unlikely(c->ro_error))
439
	if (unlikely(c->ro_error))
437
		return -EROFS;
440
		return -EROFS;
438
441
442
	printk("{WRITE_ITER} Step 1. Get page by ubifs_write_begin, ino=%lu LOCK PAGE ==\n", inode->i_ino);
439
	/* Try out the fast-path part first */
443
	/* Try out the fast-path part first */
440
	page = grab_cache_page_write_begin(mapping, index, flags);
444
	page = grab_cache_page_write_begin(mapping, index, flags);
441
	if (unlikely(!page))
445
	if (unlikely(!page))
442
		return -ENOMEM;
446
		return -ENOMEM;
443
447
448
	printk("{WRITE_ITER} Step 1. Get page %ps by ubifs_write_begin, ino=%lu LOCK PAGE --\n", page, page->mapping->host->i_ino);
444
	if (!PageUptodate(page)) {
449
	if (!PageUptodate(page)) {
445
		/* The page is not loaded from the flash */
450
		/* The page is not loaded from the flash */
446
		if (!(pos & ~PAGE_MASK) && len == PAGE_SIZE) {
451
		if (!(pos & ~PAGE_MASK) && len == PAGE_SIZE) {
Lines 586-595 static int ubifs_write_end(struct file *file, struct address_space *mapping, Link Here
586
		__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
591
		__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
587
		ubifs_assert(c, mutex_is_locked(&ui->ui_mutex));
592
		ubifs_assert(c, mutex_is_locked(&ui->ui_mutex));
588
		mutex_unlock(&ui->ui_mutex);
593
		mutex_unlock(&ui->ui_mutex);
594
		printk("{WRITE_ITER} Step 3. ubifs_write_end appending write page=%ps, ino=%lu UNLOCK UI ++\n", page, page->mapping->host->i_ino);
589
	}
595
	}
590
596
591
out:
597
out:
592
	unlock_page(page);
598
	unlock_page(page);
599
	printk("{WRITE_ITER} Step 3. Fill page %ps by ubifs_write_end, ino=%lu UNLOCK PAGE ++\n", page, page->mapping->host->i_ino);
593
	put_page(page);
600
	put_page(page);
594
	return copied;
601
	return copied;
595
}
602
}
Lines 786-797 static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu, Link Here
786
793
787
		if (page_offset > end_index)
794
		if (page_offset > end_index)
788
			break;
795
			break;
796
		msleep(400);
789
		page = find_or_create_page(mapping, page_offset, ra_gfp_mask);
797
		page = find_or_create_page(mapping, page_offset, ra_gfp_mask);
790
		if (!page)
798
		if (!page)
791
			break;
799
			break;
792
		if (!PageUptodate(page))
800
		if (!PageUptodate(page))
793
			err = populate_page(c, page, bu, &n);
801
			err = populate_page(c, page, bu, &n);
794
		unlock_page(page);
802
		unlock_page(page);
803
		printk("[READ] Step 2. ubifs_do_bulk_read page=%ps ino=%lu UNLOCK page ++\n", page, inode->i_ino);
795
		put_page(page);
804
		put_page(page);
796
		if (err)
805
		if (err)
797
			break;
806
			break;
Lines 839-846 static int ubifs_bulk_read(struct page *page) Link Here
839
	 * Bulk-read is protected by @ui->ui_mutex, but it is an optimization,
848
	 * Bulk-read is protected by @ui->ui_mutex, but it is an optimization,
840
	 * so don't bother if we cannot lock the mutex.
849
	 * so don't bother if we cannot lock the mutex.
841
	 */
850
	 */
851
	printk("[READ] Step 1. ubifs_bulk_read ino=%lu page=%ps LOCK UI ==\n", inode->i_ino, page);
852
	if (ui->read_in_a_row == 2)
853
	      msleep(100);
842
	if (!mutex_trylock(&ui->ui_mutex))
854
	if (!mutex_trylock(&ui->ui_mutex))
843
		return 0;
855
		return 0;
856
	printk("[READ] Step 1. ubifs_bulk_read ino=%lu page=%ps LOCK UI --\n", inode->i_ino, page);
844
857
845
	if (index != last_page_read + 1) {
858
	if (index != last_page_read + 1) {
846
		/* Turn off bulk-read if we stop reading sequentially */
859
		/* Turn off bulk-read if we stop reading sequentially */
Lines 885-890 static int ubifs_bulk_read(struct page *page) Link Here
885
898
886
out_unlock:
899
out_unlock:
887
	mutex_unlock(&ui->ui_mutex);
900
	mutex_unlock(&ui->ui_mutex);
901
	printk("[READ] Step 3. ubifs_bulk_read ino=%lu page=%ps bulked=%d UNLOCK UI ++\n", inode->i_ino, page, err);
888
	return err;
902
	return err;
889
}
903
}
890
904
Lines 950-955 static int do_writepage(struct page *page, int len) Link Here
950
964
951
	kunmap(page);
965
	kunmap(page);
952
	unlock_page(page);
966
	unlock_page(page);
967
	if (!strncmp(page->mapping->host->i_sb->s_type->name, "ubifs", strlen("ubifs")) && page->mapping->host->i_ino == 65)
968
		printk("<WRITE> Step 3. do_writepage page=%ps data=%c%c%c UNLOCK PAGE ++.\n", page, ((char *)kmap_atomic(page))[0], ((char *)kmap_atomic(page))[1], ((char *)kmap_atomic(page))[2]);
953
	end_page_writeback(page);
969
	end_page_writeback(page);
954
	return err;
970
	return err;
955
}
971
}
(-)a/fs/ubifs/super.c (+5 lines)
Lines 25-30 Link Here
25
#include <linux/math64.h>
25
#include <linux/math64.h>
26
#include <linux/writeback.h>
26
#include <linux/writeback.h>
27
#include "ubifs.h"
27
#include "ubifs.h"
28
#include <linux/delay.h>
28
29
29
/*
30
/*
30
 * Maximum amount of memory we may 'kmalloc()' without worrying that we are
31
 * Maximum amount of memory we may 'kmalloc()' without worrying that we are
Lines 284-290 static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc) Link Here
284
	if (is_bad_inode(inode))
285
	if (is_bad_inode(inode))
285
		return 0;
286
		return 0;
286
287
288
	printk("<WRITE> Step 2. ubifs_write_inode ino=%lu LOCK UI ==.\n", inode->i_ino);
289
	msleep(800);
287
	mutex_lock(&ui->ui_mutex);
290
	mutex_lock(&ui->ui_mutex);
291
	printk("<WRITE> Step 2. ubifs_write_inode ino=%lu LOCK UI --.\n", inode->i_ino);
288
	/*
292
	/*
289
	 * Due to races between write-back forced by budgeting
293
	 * Due to races between write-back forced by budgeting
290
	 * (see 'sync_some_inodes()') and background write-back, the inode may
294
	 * (see 'sync_some_inodes()') and background write-back, the inode may
Lines 314-319 static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc) Link Here
314
318
315
	ui->dirty = 0;
319
	ui->dirty = 0;
316
	mutex_unlock(&ui->ui_mutex);
320
	mutex_unlock(&ui->ui_mutex);
321
	printk("<WRITE> Step 2. ubifs_write_inode ino=%lu UNLOCK UI ++.\n", inode->i_ino);
317
	ubifs_release_dirty_inode_budget(c, ui);
322
	ubifs_release_dirty_inode_budget(c, ui);
318
	return err;
323
	return err;
319
}
324
}
(-)a/mm/filemap.c (+10 lines)
Lines 1639-1644 struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, Link Here
1639
		goto no_page;
1639
		goto no_page;
1640
1640
1641
	if (fgp_flags & FGP_LOCK) {
1641
	if (fgp_flags & FGP_LOCK) {
1642
		if (page->mapping->host->i_ino == 65)
1643
			printk("[READ] Step 2. pagecache_get_page page=%ps LOCK PAGE ==.\n", page);
1642
		if (fgp_flags & FGP_NOWAIT) {
1644
		if (fgp_flags & FGP_NOWAIT) {
1643
			if (!trylock_page(page)) {
1645
			if (!trylock_page(page)) {
1644
				put_page(page);
1646
				put_page(page);
Lines 1647-1652 struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, Link Here
1647
		} else {
1649
		} else {
1648
			lock_page(page);
1650
			lock_page(page);
1649
		}
1651
		}
1652
		if (page->mapping->host->i_ino == 65)
1653
			printk("[READ] Step 2. pagecache_get_page page=%ps LOCK PAGE --.\n", page);
1650
1654
1651
		/* Has the page been truncated? */
1655
		/* Has the page been truncated? */
1652
		if (unlikely(compound_head(page)->mapping != mapping)) {
1656
		if (unlikely(compound_head(page)->mapping != mapping)) {
Lines 3464-3474 ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) Link Here
3464
	struct inode *inode = file->f_mapping->host;
3468
	struct inode *inode = file->f_mapping->host;
3465
	ssize_t ret;
3469
	ssize_t ret;
3466
3470
3471
	if (inode->i_ino == 65)
3472
	      printk("{WRITE_ITER} A generic_file_write_iter, ino=%lu LOCK INODE ==\n", inode->i_ino);
3467
	inode_lock(inode);
3473
	inode_lock(inode);
3474
	if (inode->i_ino == 65)
3475
	      printk("{WRITE_ITER} B generic_file_write_iter, ino=%lu LOCK INODE --\n", inode->i_ino);
3468
	ret = generic_write_checks(iocb, from);
3476
	ret = generic_write_checks(iocb, from);
3469
	if (ret > 0)
3477
	if (ret > 0)
3470
		ret = __generic_file_write_iter(iocb, from);
3478
		ret = __generic_file_write_iter(iocb, from);
3471
	inode_unlock(inode);
3479
	inode_unlock(inode);
3480
	if (inode->i_ino == 65)
3481
	      printk("{WRITE_ITER} C generic_file_write_iter, ino=%lu UNLOCK INODE ++\n", inode->i_ino);
3472
3482
3473
	if (ret > 0)
3483
	if (ret > 0)
3474
		ret = generic_write_sync(iocb, ret);
3484
		ret = generic_write_sync(iocb, ret);
(-)a/mm/page-writeback.c (+4 lines)
Lines 2202-2208 int write_cache_pages(struct address_space *mapping, Link Here
2202
2202
2203
			done_index = page->index;
2203
			done_index = page->index;
2204
2204
2205
			if (!strncmp(page->mapping->host->i_sb->s_type->name, "ubifs", strlen("ubifs")) && page->mapping->host->i_ino == 65)
2206
				printk("<WRITE> Step 1. write_cache_pages page=%ps data=%c%c%c LOCK PAGE ==.\n", page, ((char *)kmap_atomic(page))[0], ((char *)kmap_atomic(page))[1], ((char *)kmap_atomic(page))[2]);
2205
			lock_page(page);
2207
			lock_page(page);
2208
			if (!strncmp(page->mapping->host->i_sb->s_type->name, "ubifs", strlen("ubifs")) && page->mapping->host->i_ino == 65)
2209
				printk("<WRITE> Step 1. write_cache_pages page=%ps data=%c%c%c LOCK PAGE --.\n", page, ((char *)kmap_atomic(page))[0], ((char *)kmap_atomic(page))[1], ((char *)kmap_atomic(page))[2]);
2206
2210
2207
			/*
2211
			/*
2208
			 * Page truncated or invalidated. We can freely skip it
2212
			 * Page truncated or invalidated. We can freely skip it

Return to bug 206153