aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-05 11:50:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-05 11:50:26 -0400
commit45d9a2220f6004b47c362cc7fc7cf9a73cb6353a (patch)
tree4e2217464c5cd71674a6ffff1f3dddaeb52556b7 /fs/ext4
parent2386a3b0fbb0c2dcf29694c7df9a72cb268458f0 (diff)
parent02afc27faec94c9e068517a22acf55400976c698 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile 1 from Al Viro: "Unfortunately, this merge window it'll have a be a lot of small piles - my fault, actually, for not keeping #for-next in anything that would resemble a sane shape ;-/ This pile: assorted fixes (the first 3 are -stable fodder, IMO) and cleanups + %pd/%pD formats (dentry/file pathname, up to 4 last components) + several long-standing patches from various folks. There definitely will be a lot more (starting with Miklos' check_submount_and_drop() series)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits) direct-io: Handle O_(D)SYNC AIO direct-io: Implement generic deferred AIO completions add formats for dentry/file pathnames kvm eventfd: switch to fdget powerpc kvm: use fdget switch fchmod() to fdget switch epoll_ctl() to fdget switch copy_module_from_fd() to fdget git simplify nilfs check for busy subtree ibmasmfs: don't bother passing superblock when not needed don't pass superblock to hypfs_{mkdir,create*} don't pass superblock to hypfs_diag_create_files don't pass superblock to hypfs_vm_create_files() oprofile: get rid of pointless forward declarations of struct super_block oprofilefs_create_...() do not need superblock argument oprofilefs_mkdir() doesn't need superblock argument don't bother with passing superblock to oprofile_create_stats_files() oprofile: don't bother with passing superblock to ->create_files() don't bother passing sb to oprofile_create_files() coh901318: don't open-code simple_read_from_buffer() ...
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/ext4.h11
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/inode.c28
-rw-r--r--fs/ext4/page-io.c30
-rw-r--r--fs/ext4/super.c16
5 files changed, 15 insertions, 72 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 06b488dca666..af815ea9d7cc 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -180,7 +180,6 @@ struct ext4_map_blocks {
180 * Flags for ext4_io_end->flags 180 * Flags for ext4_io_end->flags
181 */ 181 */
182#define EXT4_IO_END_UNWRITTEN 0x0001 182#define EXT4_IO_END_UNWRITTEN 0x0001
183#define EXT4_IO_END_DIRECT 0x0002
184 183
185/* 184/*
186 * For converting uninitialized extents on a work queue. 'handle' is used for 185 * For converting uninitialized extents on a work queue. 'handle' is used for
@@ -196,8 +195,6 @@ typedef struct ext4_io_end {
196 unsigned int flag; /* unwritten or not */ 195 unsigned int flag; /* unwritten or not */
197 loff_t offset; /* offset in the file */ 196 loff_t offset; /* offset in the file */
198 ssize_t size; /* size of the extent */ 197 ssize_t size; /* size of the extent */
199 struct kiocb *iocb; /* iocb struct for AIO */
200 int result; /* error value for AIO */
201 atomic_t count; /* reference counter */ 198 atomic_t count; /* reference counter */
202} ext4_io_end_t; 199} ext4_io_end_t;
203 200
@@ -914,11 +911,9 @@ struct ext4_inode_info {
914 * Completed IOs that need unwritten extents handling and don't have 911 * Completed IOs that need unwritten extents handling and don't have
915 * transaction reserved 912 * transaction reserved
916 */ 913 */
917 struct list_head i_unrsv_conversion_list;
918 atomic_t i_ioend_count; /* Number of outstanding io_end structs */ 914 atomic_t i_ioend_count; /* Number of outstanding io_end structs */
919 atomic_t i_unwritten; /* Nr. of inflight conversions pending */ 915 atomic_t i_unwritten; /* Nr. of inflight conversions pending */
920 struct work_struct i_rsv_conversion_work; 916 struct work_struct i_rsv_conversion_work;
921 struct work_struct i_unrsv_conversion_work;
922 917
923 spinlock_t i_block_reservation_lock; 918 spinlock_t i_block_reservation_lock;
924 919
@@ -1290,8 +1285,6 @@ struct ext4_sb_info {
1290 struct flex_groups *s_flex_groups; 1285 struct flex_groups *s_flex_groups;
1291 ext4_group_t s_flex_groups_allocated; 1286 ext4_group_t s_flex_groups_allocated;
1292 1287
1293 /* workqueue for unreserved extent convertions (dio) */
1294 struct workqueue_struct *unrsv_conversion_wq;
1295 /* workqueue for reserved extent conversions (buffered io) */ 1288 /* workqueue for reserved extent conversions (buffered io) */
1296 struct workqueue_struct *rsv_conversion_wq; 1289 struct workqueue_struct *rsv_conversion_wq;
1297 1290
@@ -1354,9 +1347,6 @@ static inline void ext4_set_io_unwritten_flag(struct inode *inode,
1354 struct ext4_io_end *io_end) 1347 struct ext4_io_end *io_end)
1355{ 1348{
1356 if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { 1349 if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
1357 /* Writeback has to have coversion transaction reserved */
1358 WARN_ON(EXT4_SB(inode->i_sb)->s_journal && !io_end->handle &&
1359 !(io_end->flag & EXT4_IO_END_DIRECT));
1360 io_end->flag |= EXT4_IO_END_UNWRITTEN; 1350 io_end->flag |= EXT4_IO_END_UNWRITTEN;
1361 atomic_inc(&EXT4_I(inode)->i_unwritten); 1351 atomic_inc(&EXT4_I(inode)->i_unwritten);
1362 } 1352 }
@@ -2760,7 +2750,6 @@ extern void ext4_put_io_end_defer(ext4_io_end_t *io_end);
2760extern void ext4_io_submit_init(struct ext4_io_submit *io, 2750extern void ext4_io_submit_init(struct ext4_io_submit *io,
2761 struct writeback_control *wbc); 2751 struct writeback_control *wbc);
2762extern void ext4_end_io_rsv_work(struct work_struct *work); 2752extern void ext4_end_io_rsv_work(struct work_struct *work);
2763extern void ext4_end_io_unrsv_work(struct work_struct *work);
2764extern void ext4_io_submit(struct ext4_io_submit *io); 2753extern void ext4_io_submit(struct ext4_io_submit *io);
2765extern int ext4_bio_write_page(struct ext4_io_submit *io, 2754extern int ext4_bio_write_page(struct ext4_io_submit *io,
2766 struct page *page, 2755 struct page *page,
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 319c9d26279a..3da21945ff1f 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -149,7 +149,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov,
149 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); 149 ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
150 mutex_unlock(&inode->i_mutex); 150 mutex_unlock(&inode->i_mutex);
151 151
152 if (ret > 0 || ret == -EIOCBQUEUED) { 152 if (ret > 0) {
153 ssize_t err; 153 ssize_t err;
154 154
155 err = generic_write_sync(file, pos, ret); 155 err = generic_write_sync(file, pos, ret);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 9115f2807515..c79fd7dabe79 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -727,8 +727,12 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
727 727
728 ret = ext4_map_blocks(handle, inode, &map, flags); 728 ret = ext4_map_blocks(handle, inode, &map, flags);
729 if (ret > 0) { 729 if (ret > 0) {
730 ext4_io_end_t *io_end = ext4_inode_aio(inode);
731
730 map_bh(bh, inode->i_sb, map.m_pblk); 732 map_bh(bh, inode->i_sb, map.m_pblk);
731 bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | map.m_flags; 733 bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | map.m_flags;
734 if (io_end && io_end->flag & EXT4_IO_END_UNWRITTEN)
735 set_buffer_defer_completion(bh);
732 bh->b_size = inode->i_sb->s_blocksize * map.m_len; 736 bh->b_size = inode->i_sb->s_blocksize * map.m_len;
733 ret = 0; 737 ret = 0;
734 } 738 }
@@ -3024,19 +3028,13 @@ static int ext4_get_block_write_nolock(struct inode *inode, sector_t iblock,
3024} 3028}
3025 3029
3026static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, 3030static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3027 ssize_t size, void *private, int ret, 3031 ssize_t size, void *private)
3028 bool is_async)
3029{ 3032{
3030 struct inode *inode = file_inode(iocb->ki_filp);
3031 ext4_io_end_t *io_end = iocb->private; 3033 ext4_io_end_t *io_end = iocb->private;
3032 3034
3033 /* if not async direct IO just return */ 3035 /* if not async direct IO just return */
3034 if (!io_end) { 3036 if (!io_end)
3035 inode_dio_done(inode);
3036 if (is_async)
3037 aio_complete(iocb, ret, 0);
3038 return; 3037 return;
3039 }
3040 3038
3041 ext_debug("ext4_end_io_dio(): io_end 0x%p " 3039 ext_debug("ext4_end_io_dio(): io_end 0x%p "
3042 "for inode %lu, iocb 0x%p, offset %llu, size %zd\n", 3040 "for inode %lu, iocb 0x%p, offset %llu, size %zd\n",
@@ -3046,11 +3044,7 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset,
3046 iocb->private = NULL; 3044 iocb->private = NULL;
3047 io_end->offset = offset; 3045 io_end->offset = offset;
3048 io_end->size = size; 3046 io_end->size = size;
3049 if (is_async) { 3047 ext4_put_io_end(io_end);
3050 io_end->iocb = iocb;
3051 io_end->result = ret;
3052 }
3053 ext4_put_io_end_defer(io_end);
3054} 3048}
3055 3049
3056/* 3050/*
@@ -3135,7 +3129,6 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3135 ret = -ENOMEM; 3129 ret = -ENOMEM;
3136 goto retake_lock; 3130 goto retake_lock;
3137 } 3131 }
3138 io_end->flag |= EXT4_IO_END_DIRECT;
3139 /* 3132 /*
3140 * Grab reference for DIO. Will be dropped in ext4_end_io_dio() 3133 * Grab reference for DIO. Will be dropped in ext4_end_io_dio()
3141 */ 3134 */
@@ -3180,13 +3173,6 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
3180 if (ret <= 0 && ret != -EIOCBQUEUED && iocb->private) { 3173 if (ret <= 0 && ret != -EIOCBQUEUED && iocb->private) {
3181 WARN_ON(iocb->private != io_end); 3174 WARN_ON(iocb->private != io_end);
3182 WARN_ON(io_end->flag & EXT4_IO_END_UNWRITTEN); 3175 WARN_ON(io_end->flag & EXT4_IO_END_UNWRITTEN);
3183 WARN_ON(io_end->iocb);
3184 /*
3185 * Generic code already did inode_dio_done() so we
3186 * have to clear EXT4_IO_END_DIRECT to not do it for
3187 * the second time.
3188 */
3189 io_end->flag = 0;
3190 ext4_put_io_end(io_end); 3176 ext4_put_io_end(io_end);
3191 iocb->private = NULL; 3177 iocb->private = NULL;
3192 } 3178 }
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 6625d210fb45..d7d0c7b46ed4 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -123,10 +123,6 @@ static void ext4_release_io_end(ext4_io_end_t *io_end)
123 ext4_finish_bio(bio); 123 ext4_finish_bio(bio);
124 bio_put(bio); 124 bio_put(bio);
125 } 125 }
126 if (io_end->flag & EXT4_IO_END_DIRECT)
127 inode_dio_done(io_end->inode);
128 if (io_end->iocb)
129 aio_complete(io_end->iocb, io_end->result, 0);
130 kmem_cache_free(io_end_cachep, io_end); 126 kmem_cache_free(io_end_cachep, io_end);
131} 127}
132 128
@@ -204,19 +200,14 @@ static void ext4_add_complete_io(ext4_io_end_t *io_end)
204 struct workqueue_struct *wq; 200 struct workqueue_struct *wq;
205 unsigned long flags; 201 unsigned long flags;
206 202
207 BUG_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN)); 203 /* Only reserved conversions from writeback should enter here */
204 WARN_ON(!(io_end->flag & EXT4_IO_END_UNWRITTEN));
205 WARN_ON(!io_end->handle);
208 spin_lock_irqsave(&ei->i_completed_io_lock, flags); 206 spin_lock_irqsave(&ei->i_completed_io_lock, flags);
209 if (io_end->handle) { 207 wq = EXT4_SB(io_end->inode->i_sb)->rsv_conversion_wq;
210 wq = EXT4_SB(io_end->inode->i_sb)->rsv_conversion_wq; 208 if (list_empty(&ei->i_rsv_conversion_list))
211 if (list_empty(&ei->i_rsv_conversion_list)) 209 queue_work(wq, &ei->i_rsv_conversion_work);
212 queue_work(wq, &ei->i_rsv_conversion_work); 210 list_add_tail(&io_end->list, &ei->i_rsv_conversion_list);
213 list_add_tail(&io_end->list, &ei->i_rsv_conversion_list);
214 } else {
215 wq = EXT4_SB(io_end->inode->i_sb)->unrsv_conversion_wq;
216 if (list_empty(&ei->i_unrsv_conversion_list))
217 queue_work(wq, &ei->i_unrsv_conversion_work);
218 list_add_tail(&io_end->list, &ei->i_unrsv_conversion_list);
219 }
220 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags); 211 spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);
221} 212}
222 213
@@ -256,13 +247,6 @@ void ext4_end_io_rsv_work(struct work_struct *work)
256 ext4_do_flush_completed_IO(&ei->vfs_inode, &ei->i_rsv_conversion_list); 247 ext4_do_flush_completed_IO(&ei->vfs_inode, &ei->i_rsv_conversion_list);
257} 248}
258 249
259void ext4_end_io_unrsv_work(struct work_struct *work)
260{
261 struct ext4_inode_info *ei = container_of(work, struct ext4_inode_info,
262 i_unrsv_conversion_work);
263 ext4_do_flush_completed_IO(&ei->vfs_inode, &ei->i_unrsv_conversion_list);
264}
265
266ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags) 250ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags)
267{ 251{
268 ext4_io_end_t *io = kmem_cache_zalloc(io_end_cachep, flags); 252 ext4_io_end_t *io = kmem_cache_zalloc(io_end_cachep, flags);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 42337141e79f..049c8a8bdc0e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -762,9 +762,7 @@ static void ext4_put_super(struct super_block *sb)
762 ext4_unregister_li_request(sb); 762 ext4_unregister_li_request(sb);
763 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 763 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
764 764
765 flush_workqueue(sbi->unrsv_conversion_wq);
766 flush_workqueue(sbi->rsv_conversion_wq); 765 flush_workqueue(sbi->rsv_conversion_wq);
767 destroy_workqueue(sbi->unrsv_conversion_wq);
768 destroy_workqueue(sbi->rsv_conversion_wq); 766 destroy_workqueue(sbi->rsv_conversion_wq);
769 767
770 if (sbi->s_journal) { 768 if (sbi->s_journal) {
@@ -875,14 +873,12 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
875#endif 873#endif
876 ei->jinode = NULL; 874 ei->jinode = NULL;
877 INIT_LIST_HEAD(&ei->i_rsv_conversion_list); 875 INIT_LIST_HEAD(&ei->i_rsv_conversion_list);
878 INIT_LIST_HEAD(&ei->i_unrsv_conversion_list);
879 spin_lock_init(&ei->i_completed_io_lock); 876 spin_lock_init(&ei->i_completed_io_lock);
880 ei->i_sync_tid = 0; 877 ei->i_sync_tid = 0;
881 ei->i_datasync_tid = 0; 878 ei->i_datasync_tid = 0;
882 atomic_set(&ei->i_ioend_count, 0); 879 atomic_set(&ei->i_ioend_count, 0);
883 atomic_set(&ei->i_unwritten, 0); 880 atomic_set(&ei->i_unwritten, 0);
884 INIT_WORK(&ei->i_rsv_conversion_work, ext4_end_io_rsv_work); 881 INIT_WORK(&ei->i_rsv_conversion_work, ext4_end_io_rsv_work);
885 INIT_WORK(&ei->i_unrsv_conversion_work, ext4_end_io_unrsv_work);
886 882
887 return &ei->vfs_inode; 883 return &ei->vfs_inode;
888} 884}
@@ -3995,14 +3991,6 @@ no_journal:
3995 goto failed_mount4; 3991 goto failed_mount4;
3996 } 3992 }
3997 3993
3998 EXT4_SB(sb)->unrsv_conversion_wq =
3999 alloc_workqueue("ext4-unrsv-conversion", WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
4000 if (!EXT4_SB(sb)->unrsv_conversion_wq) {
4001 printk(KERN_ERR "EXT4-fs: failed to create workqueue\n");
4002 ret = -ENOMEM;
4003 goto failed_mount4;
4004 }
4005
4006 /* 3994 /*
4007 * The jbd2_journal_load will have done any necessary log recovery, 3995 * The jbd2_journal_load will have done any necessary log recovery,
4008 * so we can safely mount the rest of the filesystem now. 3996 * so we can safely mount the rest of the filesystem now.
@@ -4156,8 +4144,6 @@ failed_mount4:
4156 ext4_msg(sb, KERN_ERR, "mount failed"); 4144 ext4_msg(sb, KERN_ERR, "mount failed");
4157 if (EXT4_SB(sb)->rsv_conversion_wq) 4145 if (EXT4_SB(sb)->rsv_conversion_wq)
4158 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); 4146 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
4159 if (EXT4_SB(sb)->unrsv_conversion_wq)
4160 destroy_workqueue(EXT4_SB(sb)->unrsv_conversion_wq);
4161failed_mount_wq: 4147failed_mount_wq:
4162 if (sbi->s_journal) { 4148 if (sbi->s_journal) {
4163 jbd2_journal_destroy(sbi->s_journal); 4149 jbd2_journal_destroy(sbi->s_journal);
@@ -4605,7 +4591,6 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
4605 4591
4606 trace_ext4_sync_fs(sb, wait); 4592 trace_ext4_sync_fs(sb, wait);
4607 flush_workqueue(sbi->rsv_conversion_wq); 4593 flush_workqueue(sbi->rsv_conversion_wq);
4608 flush_workqueue(sbi->unrsv_conversion_wq);
4609 /* 4594 /*
4610 * Writeback quota in non-journalled quota case - journalled quota has 4595 * Writeback quota in non-journalled quota case - journalled quota has
4611 * no dirty dquots 4596 * no dirty dquots
@@ -4641,7 +4626,6 @@ static int ext4_sync_fs_nojournal(struct super_block *sb, int wait)
4641 4626
4642 trace_ext4_sync_fs(sb, wait); 4627 trace_ext4_sync_fs(sb, wait);
4643 flush_workqueue(EXT4_SB(sb)->rsv_conversion_wq); 4628 flush_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
4644 flush_workqueue(EXT4_SB(sb)->unrsv_conversion_wq);
4645 dquot_writeback_dquots(sb, -1); 4629 dquot_writeback_dquots(sb, -1);
4646 if (wait && test_opt(sb, BARRIER)) 4630 if (wait && test_opt(sb, BARRIER))
4647 ret = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL); 4631 ret = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);