Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
jbd2: call __jbd2_log_start_commit with j_state_lock write locked
ext4: serialize unaligned asynchronous DIO
ext4: make grpinfo slab cache names static
ext4: Fix data corruption with multi-block writepages support
ext4: fix up ext4 error handling
ext4: unregister features interface on module unload
ext4: fix panic on module unload when stopping lazyinit thread

+222 -92
+10
fs/ext4/ext4.h
··· 848 848 atomic_t i_ioend_count; /* Number of outstanding io_end structs */ 849 849 /* current io_end structure for async DIO write*/ 850 850 ext4_io_end_t *cur_aio_dio; 851 + atomic_t i_aiodio_unwritten; /* Nr. of inflight conversions pending */ 851 852 852 853 spinlock_t i_block_reservation_lock; 853 854 ··· 2119 2118 } 2120 2119 2121 2120 #define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1) 2121 + 2122 + /* For ioend & aio unwritten conversion wait queues */ 2123 + #define EXT4_WQ_HASH_SZ 37 2124 + #define ext4_ioend_wq(v) (&ext4__ioend_wq[((unsigned long)(v)) %\ 2125 + EXT4_WQ_HASH_SZ]) 2126 + #define ext4_aio_mutex(v) (&ext4__aio_mutex[((unsigned long)(v)) %\ 2127 + EXT4_WQ_HASH_SZ]) 2128 + extern wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; 2129 + extern struct mutex ext4__aio_mutex[EXT4_WQ_HASH_SZ]; 2122 2130 2123 2131 #endif /* __KERNEL__ */ 2124 2132
+6 -4
fs/ext4/extents.c
··· 3174 3174 * that this IO needs to convertion to written when IO is 3175 3175 * completed 3176 3176 */ 3177 - if (io) 3177 + if (io && !(io->flag & EXT4_IO_END_UNWRITTEN)) { 3178 3178 io->flag = EXT4_IO_END_UNWRITTEN; 3179 - else 3179 + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); 3180 + } else 3180 3181 ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); 3181 3182 if (ext4_should_dioread_nolock(inode)) 3182 3183 map->m_flags |= EXT4_MAP_UNINIT; ··· 3464 3463 * that we need to perform convertion when IO is done. 3465 3464 */ 3466 3465 if ((flags & EXT4_GET_BLOCKS_PRE_IO)) { 3467 - if (io) 3466 + if (io && !(io->flag & EXT4_IO_END_UNWRITTEN)) { 3468 3467 io->flag = EXT4_IO_END_UNWRITTEN; 3469 - else 3468 + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); 3469 + } else 3470 3470 ext4_set_inode_state(inode, 3471 3471 EXT4_STATE_DIO_UNWRITTEN); 3472 3472 }
+59 -1
fs/ext4/file.c
··· 55 55 return 0; 56 56 } 57 57 58 + static void ext4_aiodio_wait(struct inode *inode) 59 + { 60 + wait_queue_head_t *wq = ext4_ioend_wq(inode); 61 + 62 + wait_event(*wq, (atomic_read(&EXT4_I(inode)->i_aiodio_unwritten) == 0)); 63 + } 64 + 65 + /* 66 + * This tests whether the IO in question is block-aligned or not. 67 + * Ext4 utilizes unwritten extents when hole-filling during direct IO, and they 68 + * are converted to written only after the IO is complete. Until they are 69 + * mapped, these blocks appear as holes, so dio_zero_block() will assume that 70 + * it needs to zero out portions of the start and/or end block. If 2 AIO 71 + * threads are at work on the same unwritten block, they must be synchronized 72 + * or one thread will zero the other's data, causing corruption. 73 + */ 74 + static int 75 + ext4_unaligned_aio(struct inode *inode, const struct iovec *iov, 76 + unsigned long nr_segs, loff_t pos) 77 + { 78 + struct super_block *sb = inode->i_sb; 79 + int blockmask = sb->s_blocksize - 1; 80 + size_t count = iov_length(iov, nr_segs); 81 + loff_t final_size = pos + count; 82 + 83 + if (pos >= inode->i_size) 84 + return 0; 85 + 86 + if ((pos & blockmask) || (final_size & blockmask)) 87 + return 1; 88 + 89 + return 0; 90 + } 91 + 58 92 static ssize_t 59 93 ext4_file_write(struct kiocb *iocb, const struct iovec *iov, 60 94 unsigned long nr_segs, loff_t pos) 61 95 { 62 96 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 97 + int unaligned_aio = 0; 98 + int ret; 63 99 64 100 /* 65 101 * If we have encountered a bitmap-format file, the size limit ··· 114 78 nr_segs = iov_shorten((struct iovec *)iov, nr_segs, 115 79 sbi->s_bitmap_maxbytes - pos); 116 80 } 81 + } else if (unlikely((iocb->ki_filp->f_flags & O_DIRECT) && 82 + !is_sync_kiocb(iocb))) { 83 + unaligned_aio = ext4_unaligned_aio(inode, iov, nr_segs, pos); 117 84 } 118 85 119 - return generic_file_aio_write(iocb, iov, nr_segs, pos); 86 + /* Unaligned direct AIO must be serialized; see comment above */ 87 + if (unaligned_aio) { 88 + static unsigned long unaligned_warn_time; 89 + 90 + /* Warn about this once per day */ 91 + if (printk_timed_ratelimit(&unaligned_warn_time, 60*60*24*HZ)) 92 + ext4_msg(inode->i_sb, KERN_WARNING, 93 + "Unaligned AIO/DIO on inode %ld by %s; " 94 + "performance will be poor.", 95 + inode->i_ino, current->comm); 96 + mutex_lock(ext4_aio_mutex(inode)); 97 + ext4_aiodio_wait(inode); 98 + } 99 + 100 + ret = generic_file_aio_write(iocb, iov, nr_segs, pos); 101 + 102 + if (unaligned_aio) 103 + mutex_unlock(ext4_aio_mutex(inode)); 104 + 105 + return ret; 120 106 } 121 107 122 108 static const struct vm_operations_struct ext4_file_vm_ops = {
+60 -40
fs/ext4/mballoc.c
··· 342 342 /* We create slab caches for groupinfo data structures based on the 343 343 * superblock block size. There will be one per mounted filesystem for 344 344 * each unique s_blocksize_bits */ 345 - #define NR_GRPINFO_CACHES \ 346 - (EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE + 1) 345 + #define NR_GRPINFO_CACHES 8 347 346 static struct kmem_cache *ext4_groupinfo_caches[NR_GRPINFO_CACHES]; 347 + 348 + static const char *ext4_groupinfo_slab_names[NR_GRPINFO_CACHES] = { 349 + "ext4_groupinfo_1k", "ext4_groupinfo_2k", "ext4_groupinfo_4k", 350 + "ext4_groupinfo_8k", "ext4_groupinfo_16k", "ext4_groupinfo_32k", 351 + "ext4_groupinfo_64k", "ext4_groupinfo_128k" 352 + }; 348 353 349 354 static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, 350 355 ext4_group_t group); ··· 2419 2414 return -ENOMEM; 2420 2415 } 2421 2416 2417 + static void ext4_groupinfo_destroy_slabs(void) 2418 + { 2419 + int i; 2420 + 2421 + for (i = 0; i < NR_GRPINFO_CACHES; i++) { 2422 + if (ext4_groupinfo_caches[i]) 2423 + kmem_cache_destroy(ext4_groupinfo_caches[i]); 2424 + ext4_groupinfo_caches[i] = NULL; 2425 + } 2426 + } 2427 + 2428 + static int ext4_groupinfo_create_slab(size_t size) 2429 + { 2430 + static DEFINE_MUTEX(ext4_grpinfo_slab_create_mutex); 2431 + int slab_size; 2432 + int blocksize_bits = order_base_2(size); 2433 + int cache_index = blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE; 2434 + struct kmem_cache *cachep; 2435 + 2436 + if (cache_index >= NR_GRPINFO_CACHES) 2437 + return -EINVAL; 2438 + 2439 + if (unlikely(cache_index < 0)) 2440 + cache_index = 0; 2441 + 2442 + mutex_lock(&ext4_grpinfo_slab_create_mutex); 2443 + if (ext4_groupinfo_caches[cache_index]) { 2444 + mutex_unlock(&ext4_grpinfo_slab_create_mutex); 2445 + return 0; /* Already created */ 2446 + } 2447 + 2448 + slab_size = offsetof(struct ext4_group_info, 2449 + bb_counters[blocksize_bits + 2]); 2450 + 2451 + cachep = kmem_cache_create(ext4_groupinfo_slab_names[cache_index], 2452 + slab_size, 0, SLAB_RECLAIM_ACCOUNT, 2453 + NULL); 2454 + 2455 + mutex_unlock(&ext4_grpinfo_slab_create_mutex); 2456 + if (!cachep) { 2457 + printk(KERN_EMERG "EXT4: no memory for groupinfo slab cache\n"); 2458 + return -ENOMEM; 2459 + } 2460 + 2461 + ext4_groupinfo_caches[cache_index] = cachep; 2462 + 2463 + return 0; 2464 + } 2465 + 2422 2466 int ext4_mb_init(struct super_block *sb, int needs_recovery) 2423 2467 { 2424 2468 struct ext4_sb_info *sbi = EXT4_SB(sb); ··· 2475 2421 unsigned offset; 2476 2422 unsigned max; 2477 2423 int ret; 2478 - int cache_index; 2479 - struct kmem_cache *cachep; 2480 - char *namep = NULL; 2481 2424 2482 2425 i = (sb->s_blocksize_bits + 2) * sizeof(*sbi->s_mb_offsets); 2483 2426 ··· 2491 2440 goto out; 2492 2441 } 2493 2442 2494 - cache_index = sb->s_blocksize_bits - EXT4_MIN_BLOCK_LOG_SIZE; 2495 - cachep = ext4_groupinfo_caches[cache_index]; 2496 - if (!cachep) { 2497 - char name[32]; 2498 - int len = offsetof(struct ext4_group_info, 2499 - bb_counters[sb->s_blocksize_bits + 2]); 2500 - 2501 - sprintf(name, "ext4_groupinfo_%d", sb->s_blocksize_bits); 2502 - namep = kstrdup(name, GFP_KERNEL); 2503 - if (!namep) { 2504 - ret = -ENOMEM; 2505 - goto out; 2506 - } 2507 - 2508 - /* Need to free the kmem_cache_name() when we 2509 - * destroy the slab */ 2510 - cachep = kmem_cache_create(namep, len, 0, 2511 - SLAB_RECLAIM_ACCOUNT, NULL); 2512 - if (!cachep) { 2513 - ret = -ENOMEM; 2514 - goto out; 2515 - } 2516 - ext4_groupinfo_caches[cache_index] = cachep; 2517 - } 2443 + ret = ext4_groupinfo_create_slab(sb->s_blocksize); 2444 + if (ret < 0) 2445 + goto out; 2518 2446 2519 2447 /* order 0 is regular bitmap */ 2520 2448 sbi->s_mb_maxs[0] = sb->s_blocksize << 3; ··· 2550 2520 if (ret) { 2551 2521 kfree(sbi->s_mb_offsets); 2552 2522 kfree(sbi->s_mb_maxs); 2553 - kfree(namep); 2554 2523 } 2555 2524 return ret; 2556 2525 } ··· 2763 2734 2764 2735 void ext4_exit_mballoc(void) 2765 2736 { 2766 - int i; 2767 2737 /* 2768 2738 * Wait for completion of call_rcu()'s on ext4_pspace_cachep 2769 2739 * before destroying the slab cache. ··· 2771 2743 kmem_cache_destroy(ext4_pspace_cachep); 2772 2744 kmem_cache_destroy(ext4_ac_cachep); 2773 2745 kmem_cache_destroy(ext4_free_ext_cachep); 2774 - 2775 - for (i = 0; i < NR_GRPINFO_CACHES; i++) { 2776 - struct kmem_cache *cachep = ext4_groupinfo_caches[i]; 2777 - if (cachep) { 2778 - char *name = (char *)kmem_cache_name(cachep); 2779 - kmem_cache_destroy(cachep); 2780 - kfree(name); 2781 - } 2782 - } 2746 + ext4_groupinfo_destroy_slabs(); 2783 2747 ext4_remove_debugfs_entry(); 2784 2748 } 2785 2749
+19 -17
fs/ext4/page-io.c
··· 32 32 33 33 static struct kmem_cache *io_page_cachep, *io_end_cachep; 34 34 35 - #define WQ_HASH_SZ 37 36 - #define to_ioend_wq(v) (&ioend_wq[((unsigned long)v) % WQ_HASH_SZ]) 37 - static wait_queue_head_t ioend_wq[WQ_HASH_SZ]; 38 - 39 35 int __init ext4_init_pageio(void) 40 36 { 41 - int i; 42 - 43 37 io_page_cachep = KMEM_CACHE(ext4_io_page, SLAB_RECLAIM_ACCOUNT); 44 38 if (io_page_cachep == NULL) 45 39 return -ENOMEM; ··· 42 48 kmem_cache_destroy(io_page_cachep); 43 49 return -ENOMEM; 44 50 } 45 - for (i = 0; i < WQ_HASH_SZ; i++) 46 - init_waitqueue_head(&ioend_wq[i]); 47 - 48 51 return 0; 49 52 } 50 53 ··· 53 62 54 63 void ext4_ioend_wait(struct inode *inode) 55 64 { 56 - wait_queue_head_t *wq = to_ioend_wq(inode); 65 + wait_queue_head_t *wq = ext4_ioend_wq(inode); 57 66 58 67 wait_event(*wq, (atomic_read(&EXT4_I(inode)->i_ioend_count) == 0)); 59 68 } ··· 78 87 for (i = 0; i < io->num_io_pages; i++) 79 88 put_io_page(io->pages[i]); 80 89 io->num_io_pages = 0; 81 - wq = to_ioend_wq(io->inode); 90 + wq = ext4_ioend_wq(io->inode); 82 91 if (atomic_dec_and_test(&EXT4_I(io->inode)->i_ioend_count) && 83 92 waitqueue_active(wq)) 84 93 wake_up_all(wq); ··· 93 102 struct inode *inode = io->inode; 94 103 loff_t offset = io->offset; 95 104 ssize_t size = io->size; 105 + wait_queue_head_t *wq; 96 106 int ret = 0; 97 107 98 108 ext4_debug("ext4_end_io_nolock: io 0x%p from inode %lu,list->next 0x%p," ··· 118 126 if (io->iocb) 119 127 aio_complete(io->iocb, io->result, 0); 120 128 /* clear the DIO AIO unwritten flag */ 121 - io->flag &= ~EXT4_IO_END_UNWRITTEN; 129 + if (io->flag & EXT4_IO_END_UNWRITTEN) { 130 + io->flag &= ~EXT4_IO_END_UNWRITTEN; 131 + /* Wake up anyone waiting on unwritten extent conversion */ 132 + wq = ext4_ioend_wq(io->inode); 133 + if (atomic_dec_and_test(&EXT4_I(inode)->i_aiodio_unwritten) && 134 + waitqueue_active(wq)) { 135 + wake_up_all(wq); 136 + } 137 + } 138 + 122 139 return ret; 123 140 } 124 141 ··· 191 190 struct inode *inode; 192 191 unsigned long flags; 193 192 int i; 193 + sector_t bi_sector = bio->bi_sector; 194 194 195 195 BUG_ON(!io_end); 196 196 bio->bi_private = NULL; ··· 209 207 if (error) 210 208 SetPageError(page); 211 209 BUG_ON(!head); 212 - if (head->b_size == PAGE_CACHE_SIZE) 213 - clear_buffer_dirty(head); 214 - else { 210 + if (head->b_size != PAGE_CACHE_SIZE) { 215 211 loff_t offset; 216 212 loff_t io_end_offset = io_end->offset + io_end->size; 217 213 ··· 221 221 if (error) 222 222 buffer_io_error(bh); 223 223 224 - clear_buffer_dirty(bh); 225 224 } 226 225 if (buffer_delay(bh)) 227 226 partial_write = 1; ··· 256 257 (unsigned long long) io_end->offset, 257 258 (long) io_end->size, 258 259 (unsigned long long) 259 - bio->bi_sector >> (inode->i_blkbits - 9)); 260 + bi_sector >> (inode->i_blkbits - 9)); 260 261 } 261 262 262 263 /* Add the io_end to per-inode completed io list*/ ··· 379 380 380 381 blocksize = 1 << inode->i_blkbits; 381 382 383 + BUG_ON(!PageLocked(page)); 382 384 BUG_ON(PageWriteback(page)); 383 385 set_page_writeback(page); 384 386 ClearPageError(page); ··· 397 397 for (bh = head = page_buffers(page), block_start = 0; 398 398 bh != head || !block_start; 399 399 block_start = block_end, bh = bh->b_this_page) { 400 + 400 401 block_end = block_start + blocksize; 401 402 if (block_start >= len) { 402 403 clear_buffer_dirty(bh); 403 404 set_buffer_uptodate(bh); 404 405 continue; 405 406 } 407 + clear_buffer_dirty(bh); 406 408 ret = io_submit_add_bh(io, io_page, inode, wbc, bh); 407 409 if (ret) { 408 410 /*
+47 -21
fs/ext4/super.c
··· 77 77 const char *dev_name, void *data); 78 78 static void ext4_destroy_lazyinit_thread(void); 79 79 static void ext4_unregister_li_request(struct super_block *sb); 80 + static void ext4_clear_request_list(void); 80 81 81 82 #if !defined(CONFIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) 82 83 static struct file_system_type ext3_fs_type = { ··· 833 832 ei->i_sync_tid = 0; 834 833 ei->i_datasync_tid = 0; 835 834 atomic_set(&ei->i_ioend_count, 0); 835 + atomic_set(&ei->i_aiodio_unwritten, 0); 836 836 837 837 return &ei->vfs_inode; 838 838 } ··· 2718 2716 mutex_unlock(&ext4_li_info->li_list_mtx); 2719 2717 } 2720 2718 2719 + static struct task_struct *ext4_lazyinit_task; 2720 + 2721 2721 /* 2722 2722 * This is the function where ext4lazyinit thread lives. It walks 2723 2723 * through the request list searching for next scheduled filesystem. ··· 2788 2784 if (time_before(jiffies, next_wakeup)) 2789 2785 schedule(); 2790 2786 finish_wait(&eli->li_wait_daemon, &wait); 2787 + if (kthread_should_stop()) { 2788 + ext4_clear_request_list(); 2789 + goto exit_thread; 2790 + } 2791 2791 } 2792 2792 2793 2793 exit_thread: ··· 2816 2808 wake_up(&eli->li_wait_task); 2817 2809 2818 2810 kfree(ext4_li_info); 2811 + ext4_lazyinit_task = NULL; 2819 2812 ext4_li_info = NULL; 2820 2813 mutex_unlock(&ext4_li_mtx); 2821 2814 ··· 2839 2830 2840 2831 static int ext4_run_lazyinit_thread(void) 2841 2832 { 2842 - struct task_struct *t; 2843 - 2844 - t = kthread_run(ext4_lazyinit_thread, ext4_li_info, "ext4lazyinit"); 2845 - if (IS_ERR(t)) { 2846 - int err = PTR_ERR(t); 2833 + ext4_lazyinit_task = kthread_run(ext4_lazyinit_thread, 2834 + ext4_li_info, "ext4lazyinit"); 2835 + if (IS_ERR(ext4_lazyinit_task)) { 2836 + int err = PTR_ERR(ext4_lazyinit_task); 2847 2837 ext4_clear_request_list(); 2848 2838 del_timer_sync(&ext4_li_info->li_timer); 2849 2839 kfree(ext4_li_info); ··· 2993 2985 * If thread exited earlier 2994 2986 * there's nothing to be done. 2995 2987 */ 2996 - if (!ext4_li_info) 2988 + if (!ext4_li_info || !ext4_lazyinit_task) 2997 2989 return; 2998 2990 2999 - ext4_clear_request_list(); 3000 - 3001 - while (ext4_li_info->li_task) { 3002 - wake_up(&ext4_li_info->li_wait_daemon); 3003 - wait_event(ext4_li_info->li_wait_task, 3004 - ext4_li_info->li_task == NULL); 3005 - } 2991 + kthread_stop(ext4_lazyinit_task); 3006 2992 } 3007 2993 3008 2994 static int ext4_fill_super(struct super_block *sb, void *data, int silent) ··· 4770 4768 .fs_flags = FS_REQUIRES_DEV, 4771 4769 }; 4772 4770 4773 - int __init ext4_init_feat_adverts(void) 4771 + static int __init ext4_init_feat_adverts(void) 4774 4772 { 4775 4773 struct ext4_features *ef; 4776 4774 int ret = -ENOMEM; ··· 4794 4792 return ret; 4795 4793 } 4796 4794 4795 + static void ext4_exit_feat_adverts(void) 4796 + { 4797 + kobject_put(&ext4_feat->f_kobj); 4798 + wait_for_completion(&ext4_feat->f_kobj_unregister); 4799 + kfree(ext4_feat); 4800 + } 4801 + 4802 + /* Shared across all ext4 file systems */ 4803 + wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; 4804 + struct mutex ext4__aio_mutex[EXT4_WQ_HASH_SZ]; 4805 + 4797 4806 static int __init ext4_init_fs(void) 4798 4807 { 4799 - int err; 4808 + int i, err; 4800 4809 4801 4810 ext4_check_flag_values(); 4811 + 4812 + for (i = 0; i < EXT4_WQ_HASH_SZ; i++) { 4813 + mutex_init(&ext4__aio_mutex[i]); 4814 + init_waitqueue_head(&ext4__ioend_wq[i]); 4815 + } 4816 + 4802 4817 err = ext4_init_pageio(); 4803 4818 if (err) 4804 4819 return err; 4805 4820 err = ext4_init_system_zone(); 4806 4821 if (err) 4807 - goto out5; 4822 + goto out7; 4808 4823 ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj); 4809 4824 if (!ext4_kset) 4810 - goto out4; 4825 + goto out6; 4811 4826 ext4_proc_root = proc_mkdir("fs/ext4", NULL); 4827 + if (!ext4_proc_root) 4828 + goto out5; 4812 4829 4813 4830 err = ext4_init_feat_adverts(); 4831 + if (err) 4832 + goto out4; 4814 4833 4815 4834 err = ext4_init_mballoc(); 4816 4835 if (err) ··· 4861 4838 out2: 4862 4839 ext4_exit_mballoc(); 4863 4840 out3: 4864 - kfree(ext4_feat); 4865 - remove_proc_entry("fs/ext4", NULL); 4866 - kset_unregister(ext4_kset); 4841 + ext4_exit_feat_adverts(); 4867 4842 out4: 4868 - ext4_exit_system_zone(); 4843 + remove_proc_entry("fs/ext4", NULL); 4869 4844 out5: 4845 + kset_unregister(ext4_kset); 4846 + out6: 4847 + ext4_exit_system_zone(); 4848 + out7: 4870 4849 ext4_exit_pageio(); 4871 4850 return err; 4872 4851 } ··· 4882 4857 destroy_inodecache(); 4883 4858 ext4_exit_xattr(); 4884 4859 ext4_exit_mballoc(); 4860 + ext4_exit_feat_adverts(); 4885 4861 remove_proc_entry("fs/ext4", NULL); 4886 4862 kset_unregister(ext4_kset); 4887 4863 ext4_exit_system_zone();
+7 -2
fs/jbd2/journal.c
··· 473 473 } 474 474 475 475 /* 476 - * Called under j_state_lock. Returns true if a transaction commit was started. 476 + * Called with j_state_lock locked for writing. 477 + * Returns true if a transaction commit was started. 477 478 */ 478 479 int __jbd2_log_start_commit(journal_t *journal, tid_t target) 479 480 { ··· 521 520 { 522 521 transaction_t *transaction = NULL; 523 522 tid_t tid; 523 + int need_to_start = 0; 524 524 525 525 read_lock(&journal->j_state_lock); 526 526 if (journal->j_running_transaction && !current->journal_info) { 527 527 transaction = journal->j_running_transaction; 528 - __jbd2_log_start_commit(journal, transaction->t_tid); 528 + if (!tid_geq(journal->j_commit_request, transaction->t_tid)) 529 + need_to_start = 1; 529 530 } else if (journal->j_committing_transaction) 530 531 transaction = journal->j_committing_transaction; 531 532 ··· 538 535 539 536 tid = transaction->t_tid; 540 537 read_unlock(&journal->j_state_lock); 538 + if (need_to_start) 539 + jbd2_log_start_commit(journal, tid); 541 540 jbd2_log_wait_commit(journal, tid); 542 541 return 1; 543 542 }
+14 -7
fs/jbd2/transaction.c
··· 117 117 static int start_this_handle(journal_t *journal, handle_t *handle, 118 118 int gfp_mask) 119 119 { 120 - transaction_t *transaction; 121 - int needed; 122 - int nblocks = handle->h_buffer_credits; 123 - transaction_t *new_transaction = NULL; 120 + transaction_t *transaction, *new_transaction = NULL; 121 + tid_t tid; 122 + int needed, need_to_start; 123 + int nblocks = handle->h_buffer_credits; 124 124 125 125 if (nblocks > journal->j_max_transaction_buffers) { 126 126 printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n", ··· 222 222 atomic_sub(nblocks, &transaction->t_outstanding_credits); 223 223 prepare_to_wait(&journal->j_wait_transaction_locked, &wait, 224 224 TASK_UNINTERRUPTIBLE); 225 - __jbd2_log_start_commit(journal, transaction->t_tid); 225 + tid = transaction->t_tid; 226 + need_to_start = !tid_geq(journal->j_commit_request, tid); 226 227 read_unlock(&journal->j_state_lock); 228 + if (need_to_start) 229 + jbd2_log_start_commit(journal, tid); 227 230 schedule(); 228 231 finish_wait(&journal->j_wait_transaction_locked, &wait); 229 232 goto repeat; ··· 445 442 { 446 443 transaction_t *transaction = handle->h_transaction; 447 444 journal_t *journal = transaction->t_journal; 448 - int ret; 445 + tid_t tid; 446 + int need_to_start, ret; 449 447 450 448 /* If we've had an abort of any type, don't even think about 451 449 * actually doing the restart! */ ··· 469 465 spin_unlock(&transaction->t_handle_lock); 470 466 471 467 jbd_debug(2, "restarting handle %p\n", handle); 472 - __jbd2_log_start_commit(journal, transaction->t_tid); 468 + tid = transaction->t_tid; 469 + need_to_start = !tid_geq(journal->j_commit_request, tid); 473 470 read_unlock(&journal->j_state_lock); 471 + if (need_to_start) 472 + jbd2_log_start_commit(journal, tid); 474 473 475 474 lock_map_release(&handle->h_lockdep_map); 476 475 handle->h_buffer_credits = nblocks;