aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/balloc.c17
-rw-r--r--fs/ext3/fsync.c10
-rw-r--r--fs/ext3/ialloc.c45
-rw-r--r--fs/ext3/ioctl.c24
-rw-r--r--fs/ext3/super.c12
5 files changed, 18 insertions, 90 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 6386d76f44a7..a2038928f9a3 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -427,7 +427,7 @@ static inline int rsv_is_empty(struct ext3_reserve_window *rsv)
427void ext3_init_block_alloc_info(struct inode *inode) 427void ext3_init_block_alloc_info(struct inode *inode)
428{ 428{
429 struct ext3_inode_info *ei = EXT3_I(inode); 429 struct ext3_inode_info *ei = EXT3_I(inode);
430 struct ext3_block_alloc_info *block_i = ei->i_block_alloc_info; 430 struct ext3_block_alloc_info *block_i;
431 struct super_block *sb = inode->i_sb; 431 struct super_block *sb = inode->i_sb;
432 432
433 block_i = kmalloc(sizeof(*block_i), GFP_NOFS); 433 block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
@@ -1440,14 +1440,14 @@ out:
1440 * 1440 *
1441 * Check if filesystem has at least 1 free block available for allocation. 1441 * Check if filesystem has at least 1 free block available for allocation.
1442 */ 1442 */
1443static int ext3_has_free_blocks(struct ext3_sb_info *sbi) 1443static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
1444{ 1444{
1445 ext3_fsblk_t free_blocks, root_blocks; 1445 ext3_fsblk_t free_blocks, root_blocks;
1446 1446
1447 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); 1447 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
1448 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count); 1448 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
1449 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) && 1449 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
1450 sbi->s_resuid != current_fsuid() && 1450 !use_reservation && sbi->s_resuid != current_fsuid() &&
1451 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) { 1451 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) {
1452 return 0; 1452 return 0;
1453 } 1453 }
@@ -1468,7 +1468,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
1468 */ 1468 */
1469int ext3_should_retry_alloc(struct super_block *sb, int *retries) 1469int ext3_should_retry_alloc(struct super_block *sb, int *retries)
1470{ 1470{
1471 if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3) 1471 if (!ext3_has_free_blocks(EXT3_SB(sb), 0) || (*retries)++ > 3)
1472 return 0; 1472 return 0;
1473 1473
1474 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); 1474 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
@@ -1546,7 +1546,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1546 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0)) 1546 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
1547 my_rsv = &block_i->rsv_window_node; 1547 my_rsv = &block_i->rsv_window_node;
1548 1548
1549 if (!ext3_has_free_blocks(sbi)) { 1549 if (!ext3_has_free_blocks(sbi, IS_NOQUOTA(inode))) {
1550 *errp = -ENOSPC; 1550 *errp = -ENOSPC;
1551 goto out; 1551 goto out;
1552 } 1552 }
@@ -1924,9 +1924,10 @@ unsigned long ext3_bg_num_gdb(struct super_block *sb, int group)
1924 * reaches any used block. Then issue a TRIM command on this extent and free 1924 * reaches any used block. Then issue a TRIM command on this extent and free
1925 * the extent in the block bitmap. This is done until whole group is scanned. 1925 * the extent in the block bitmap. This is done until whole group is scanned.
1926 */ 1926 */
1927ext3_grpblk_t ext3_trim_all_free(struct super_block *sb, unsigned int group, 1927static ext3_grpblk_t ext3_trim_all_free(struct super_block *sb,
1928 ext3_grpblk_t start, ext3_grpblk_t max, 1928 unsigned int group,
1929 ext3_grpblk_t minblocks) 1929 ext3_grpblk_t start, ext3_grpblk_t max,
1930 ext3_grpblk_t minblocks)
1930{ 1931{
1931 handle_t *handle; 1932 handle_t *handle;
1932 ext3_grpblk_t next, free_blocks, bit, freed, count = 0; 1933 ext3_grpblk_t next, free_blocks, bit, freed, count = 0;
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index d494c554c6e6..1860ed356323 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -61,13 +61,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
61 if (ret) 61 if (ret)
62 goto out; 62 goto out;
63 63
64 /*
65 * Taking the mutex here just to keep consistent with how fsync was
66 * called previously, however it looks like we don't need to take
67 * i_mutex at all.
68 */
69 mutex_lock(&inode->i_mutex);
70
71 J_ASSERT(ext3_journal_current_handle() == NULL); 64 J_ASSERT(ext3_journal_current_handle() == NULL);
72 65
73 /* 66 /*
@@ -85,7 +78,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
85 * safe in-journal, which is all fsync() needs to ensure. 78 * safe in-journal, which is all fsync() needs to ensure.
86 */ 79 */
87 if (ext3_should_journal_data(inode)) { 80 if (ext3_should_journal_data(inode)) {
88 mutex_unlock(&inode->i_mutex);
89 ret = ext3_force_commit(inode->i_sb); 81 ret = ext3_force_commit(inode->i_sb);
90 goto out; 82 goto out;
91 } 83 }
@@ -108,8 +100,6 @@ int ext3_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
108 */ 100 */
109 if (needs_barrier) 101 if (needs_barrier)
110 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); 102 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
111
112 mutex_unlock(&inode->i_mutex);
113out: 103out:
114 trace_ext3_sync_file_exit(inode, ret); 104 trace_ext3_sync_file_exit(inode, ret);
115 return ret; 105 return ret;
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 835d4ea61b0e..5c866e06e7ab 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -178,42 +178,6 @@ error_return:
178} 178}
179 179
180/* 180/*
181 * There are two policies for allocating an inode. If the new inode is
182 * a directory, then a forward search is made for a block group with both
183 * free space and a low directory-to-inode ratio; if that fails, then of
184 * the groups with above-average free space, that group with the fewest
185 * directories already is chosen.
186 *
187 * For other inodes, search forward from the parent directory\'s block
188 * group to find a free inode.
189 */
190static int find_group_dir(struct super_block *sb, struct inode *parent)
191{
192 int ngroups = EXT3_SB(sb)->s_groups_count;
193 unsigned int freei, avefreei;
194 struct ext3_group_desc *desc, *best_desc = NULL;
195 int group, best_group = -1;
196
197 freei = percpu_counter_read_positive(&EXT3_SB(sb)->s_freeinodes_counter);
198 avefreei = freei / ngroups;
199
200 for (group = 0; group < ngroups; group++) {
201 desc = ext3_get_group_desc (sb, group, NULL);
202 if (!desc || !desc->bg_free_inodes_count)
203 continue;
204 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
205 continue;
206 if (!best_desc ||
207 (le16_to_cpu(desc->bg_free_blocks_count) >
208 le16_to_cpu(best_desc->bg_free_blocks_count))) {
209 best_group = group;
210 best_desc = desc;
211 }
212 }
213 return best_group;
214}
215
216/*
217 * Orlov's allocator for directories. 181 * Orlov's allocator for directories.
218 * 182 *
219 * We always try to spread first-level directories. 183 * We always try to spread first-level directories.
@@ -436,12 +400,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
436 400
437 sbi = EXT3_SB(sb); 401 sbi = EXT3_SB(sb);
438 es = sbi->s_es; 402 es = sbi->s_es;
439 if (S_ISDIR(mode)) { 403 if (S_ISDIR(mode))
440 if (test_opt (sb, OLDALLOC)) 404 group = find_group_orlov(sb, dir);
441 group = find_group_dir(sb, dir); 405 else
442 else
443 group = find_group_orlov(sb, dir);
444 } else
445 group = find_group_other(sb, dir); 406 group = find_group_other(sb, dir);
446 407
447 err = -ENOSPC; 408 err = -ENOSPC;
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index c7f43944f160..ba1b54e23cae 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -150,30 +150,6 @@ setversion_out:
150 mnt_drop_write(filp->f_path.mnt); 150 mnt_drop_write(filp->f_path.mnt);
151 return err; 151 return err;
152 } 152 }
153#ifdef CONFIG_JBD_DEBUG
154 case EXT3_IOC_WAIT_FOR_READONLY:
155 /*
156 * This is racy - by the time we're woken up and running,
157 * the superblock could be released. And the module could
158 * have been unloaded. So sue me.
159 *
160 * Returns 1 if it slept, else zero.
161 */
162 {
163 struct super_block *sb = inode->i_sb;
164 DECLARE_WAITQUEUE(wait, current);
165 int ret = 0;
166
167 set_current_state(TASK_INTERRUPTIBLE);
168 add_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
169 if (timer_pending(&EXT3_SB(sb)->turn_ro_timer)) {
170 schedule();
171 ret = 1;
172 }
173 remove_wait_queue(&EXT3_SB(sb)->ro_wait_queue, &wait);
174 return ret;
175 }
176#endif
177 case EXT3_IOC_GETRSVSZ: 153 case EXT3_IOC_GETRSVSZ:
178 if (test_opt(inode->i_sb, RESERVATION) 154 if (test_opt(inode->i_sb, RESERVATION)
179 && S_ISREG(inode->i_mode) 155 && S_ISREG(inode->i_mode)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7beb69ae0015..922d289aeeb3 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -652,8 +652,6 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
652 seq_puts(seq, ",nouid32"); 652 seq_puts(seq, ",nouid32");
653 if (test_opt(sb, DEBUG)) 653 if (test_opt(sb, DEBUG))
654 seq_puts(seq, ",debug"); 654 seq_puts(seq, ",debug");
655 if (test_opt(sb, OLDALLOC))
656 seq_puts(seq, ",oldalloc");
657#ifdef CONFIG_EXT3_FS_XATTR 655#ifdef CONFIG_EXT3_FS_XATTR
658 if (test_opt(sb, XATTR_USER)) 656 if (test_opt(sb, XATTR_USER))
659 seq_puts(seq, ",user_xattr"); 657 seq_puts(seq, ",user_xattr");
@@ -1049,10 +1047,12 @@ static int parse_options (char *options, struct super_block *sb,
1049 set_opt (sbi->s_mount_opt, DEBUG); 1047 set_opt (sbi->s_mount_opt, DEBUG);
1050 break; 1048 break;
1051 case Opt_oldalloc: 1049 case Opt_oldalloc:
1052 set_opt (sbi->s_mount_opt, OLDALLOC); 1050 ext3_msg(sb, KERN_WARNING,
1051 "Ignoring deprecated oldalloc option");
1053 break; 1052 break;
1054 case Opt_orlov: 1053 case Opt_orlov:
1055 clear_opt (sbi->s_mount_opt, OLDALLOC); 1054 ext3_msg(sb, KERN_WARNING,
1055 "Ignoring deprecated orlov option");
1056 break; 1056 break;
1057#ifdef CONFIG_EXT3_FS_XATTR 1057#ifdef CONFIG_EXT3_FS_XATTR
1058 case Opt_user_xattr: 1058 case Opt_user_xattr:
@@ -2669,13 +2669,13 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2669 /* 2669 /*
2670 * If we have an unprocessed orphan list hanging 2670 * If we have an unprocessed orphan list hanging
2671 * around from a previously readonly bdev mount, 2671 * around from a previously readonly bdev mount,
2672 * require a full umount/remount for now. 2672 * require a full umount & mount for now.
2673 */ 2673 */
2674 if (es->s_last_orphan) { 2674 if (es->s_last_orphan) {
2675 ext3_msg(sb, KERN_WARNING, "warning: couldn't " 2675 ext3_msg(sb, KERN_WARNING, "warning: couldn't "
2676 "remount RDWR because of unprocessed " 2676 "remount RDWR because of unprocessed "
2677 "orphan inode list. Please " 2677 "orphan inode list. Please "
2678 "umount/remount instead."); 2678 "umount & mount instead.");
2679 err = -EINVAL; 2679 err = -EINVAL;
2680 goto restore_opts; 2680 goto restore_opts;
2681 } 2681 }