aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2')
-rw-r--r--fs/ext2/dir.c8
-rw-r--r--fs/ext2/ext2.h9
-rw-r--r--fs/ext2/file.c6
-rw-r--r--fs/ext2/inode.c14
-rw-r--r--fs/ext2/namei.c54
-rw-r--r--fs/ext2/super.c6
6 files changed, 35 insertions, 62 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index b3dbd716cd3a..d672aa9f4061 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -416,8 +416,7 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
416 416
417 lock_page(page); 417 lock_page(page);
418 err = page->mapping->a_ops->prepare_write(NULL, page, from, to); 418 err = page->mapping->a_ops->prepare_write(NULL, page, from, to);
419 if (err) 419 BUG_ON(err);
420 BUG();
421 de->inode = cpu_to_le32(inode->i_ino); 420 de->inode = cpu_to_le32(inode->i_ino);
422 ext2_set_de_type (de, inode); 421 ext2_set_de_type (de, inode);
423 err = ext2_commit_chunk(page, from, to); 422 err = ext2_commit_chunk(page, from, to);
@@ -554,8 +553,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
554 from = (char*)pde - (char*)page_address(page); 553 from = (char*)pde - (char*)page_address(page);
555 lock_page(page); 554 lock_page(page);
556 err = mapping->a_ops->prepare_write(NULL, page, from, to); 555 err = mapping->a_ops->prepare_write(NULL, page, from, to);
557 if (err) 556 BUG_ON(err);
558 BUG();
559 if (pde) 557 if (pde)
560 pde->rec_len = cpu_to_le16(to-from); 558 pde->rec_len = cpu_to_le16(to-from);
561 dir->inode = 0; 559 dir->inode = 0;
@@ -660,7 +658,7 @@ not_empty:
660 return 0; 658 return 0;
661} 659}
662 660
663struct file_operations ext2_dir_operations = { 661const struct file_operations ext2_dir_operations = {
664 .llseek = generic_file_llseek, 662 .llseek = generic_file_llseek,
665 .read = generic_read_dir, 663 .read = generic_read_dir,
666 .readdir = ext2_readdir, 664 .readdir = ext2_readdir,
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 00de0a7312a2..9f74a62be555 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -138,6 +138,9 @@ extern void ext2_set_inode_flags(struct inode *inode);
138extern int ext2_ioctl (struct inode *, struct file *, unsigned int, 138extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
139 unsigned long); 139 unsigned long);
140 140
141/* namei.c */
142struct dentry *ext2_get_parent(struct dentry *child);
143
141/* super.c */ 144/* super.c */
142extern void ext2_error (struct super_block *, const char *, const char *, ...) 145extern void ext2_error (struct super_block *, const char *, const char *, ...)
143 __attribute__ ((format (printf, 3, 4))); 146 __attribute__ ((format (printf, 3, 4)));
@@ -151,12 +154,12 @@ extern void ext2_write_super (struct super_block *);
151 */ 154 */
152 155
153/* dir.c */ 156/* dir.c */
154extern struct file_operations ext2_dir_operations; 157extern const struct file_operations ext2_dir_operations;
155 158
156/* file.c */ 159/* file.c */
157extern struct inode_operations ext2_file_inode_operations; 160extern struct inode_operations ext2_file_inode_operations;
158extern struct file_operations ext2_file_operations; 161extern const struct file_operations ext2_file_operations;
159extern struct file_operations ext2_xip_file_operations; 162extern const struct file_operations ext2_xip_file_operations;
160 163
161/* inode.c */ 164/* inode.c */
162extern struct address_space_operations ext2_aops; 165extern struct address_space_operations ext2_aops;
diff --git a/fs/ext2/file.c b/fs/ext2/file.c
index a484412fc782..23e2c7ccec1d 100644
--- a/fs/ext2/file.c
+++ b/fs/ext2/file.c
@@ -39,7 +39,7 @@ static int ext2_release_file (struct inode * inode, struct file * filp)
39 * We have mostly NULL's here: the current defaults are ok for 39 * We have mostly NULL's here: the current defaults are ok for
40 * the ext2 filesystem. 40 * the ext2 filesystem.
41 */ 41 */
42struct file_operations ext2_file_operations = { 42const struct file_operations ext2_file_operations = {
43 .llseek = generic_file_llseek, 43 .llseek = generic_file_llseek,
44 .read = generic_file_read, 44 .read = generic_file_read,
45 .write = generic_file_write, 45 .write = generic_file_write,
@@ -53,10 +53,12 @@ struct file_operations ext2_file_operations = {
53 .readv = generic_file_readv, 53 .readv = generic_file_readv,
54 .writev = generic_file_writev, 54 .writev = generic_file_writev,
55 .sendfile = generic_file_sendfile, 55 .sendfile = generic_file_sendfile,
56 .splice_read = generic_file_splice_read,
57 .splice_write = generic_file_splice_write,
56}; 58};
57 59
58#ifdef CONFIG_EXT2_FS_XIP 60#ifdef CONFIG_EXT2_FS_XIP
59struct file_operations ext2_xip_file_operations = { 61const struct file_operations ext2_xip_file_operations = {
60 .llseek = generic_file_llseek, 62 .llseek = generic_file_llseek,
61 .read = xip_file_read, 63 .read = xip_file_read,
62 .write = xip_file_write, 64 .write = xip_file_write,
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index a717837f272e..04af9c45dce2 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -667,18 +667,6 @@ static sector_t ext2_bmap(struct address_space *mapping, sector_t block)
667 return generic_block_bmap(mapping,block,ext2_get_block); 667 return generic_block_bmap(mapping,block,ext2_get_block);
668} 668}
669 669
670static int
671ext2_get_blocks(struct inode *inode, sector_t iblock, unsigned long max_blocks,
672 struct buffer_head *bh_result, int create)
673{
674 int ret;
675
676 ret = ext2_get_block(inode, iblock, bh_result, create);
677 if (ret == 0)
678 bh_result->b_size = (1 << inode->i_blkbits);
679 return ret;
680}
681
682static ssize_t 670static ssize_t
683ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, 671ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
684 loff_t offset, unsigned long nr_segs) 672 loff_t offset, unsigned long nr_segs)
@@ -687,7 +675,7 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
687 struct inode *inode = file->f_mapping->host; 675 struct inode *inode = file->f_mapping->host;
688 676
689 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 677 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
690 offset, nr_segs, ext2_get_blocks, NULL); 678 offset, nr_segs, ext2_get_block, NULL);
691} 679}
692 680
693static int 681static int
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index ad1432a2a62e..4ca824985321 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -36,22 +36,6 @@
36#include "acl.h" 36#include "acl.h"
37#include "xip.h" 37#include "xip.h"
38 38
39/*
40 * Couple of helper functions - make the code slightly cleaner.
41 */
42
43static inline void ext2_inc_count(struct inode *inode)
44{
45 inode->i_nlink++;
46 mark_inode_dirty(inode);
47}
48
49static inline void ext2_dec_count(struct inode *inode)
50{
51 inode->i_nlink--;
52 mark_inode_dirty(inode);
53}
54
55static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) 39static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
56{ 40{
57 int err = ext2_add_link(dentry, inode); 41 int err = ext2_add_link(dentry, inode);
@@ -59,7 +43,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
59 d_instantiate(dentry, inode); 43 d_instantiate(dentry, inode);
60 return 0; 44 return 0;
61 } 45 }
62 ext2_dec_count(inode); 46 inode_dec_link_count(inode);
63 iput(inode); 47 iput(inode);
64 return err; 48 return err;
65} 49}
@@ -201,7 +185,7 @@ out:
201 return err; 185 return err;
202 186
203out_fail: 187out_fail:
204 ext2_dec_count(inode); 188 inode_dec_link_count(inode);
205 iput (inode); 189 iput (inode);
206 goto out; 190 goto out;
207} 191}
@@ -215,7 +199,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
215 return -EMLINK; 199 return -EMLINK;
216 200
217 inode->i_ctime = CURRENT_TIME_SEC; 201 inode->i_ctime = CURRENT_TIME_SEC;
218 ext2_inc_count(inode); 202 inode_inc_link_count(inode);
219 atomic_inc(&inode->i_count); 203 atomic_inc(&inode->i_count);
220 204
221 return ext2_add_nondir(dentry, inode); 205 return ext2_add_nondir(dentry, inode);
@@ -229,7 +213,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
229 if (dir->i_nlink >= EXT2_LINK_MAX) 213 if (dir->i_nlink >= EXT2_LINK_MAX)
230 goto out; 214 goto out;
231 215
232 ext2_inc_count(dir); 216 inode_inc_link_count(dir);
233 217
234 inode = ext2_new_inode (dir, S_IFDIR | mode); 218 inode = ext2_new_inode (dir, S_IFDIR | mode);
235 err = PTR_ERR(inode); 219 err = PTR_ERR(inode);
@@ -243,7 +227,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
243 else 227 else
244 inode->i_mapping->a_ops = &ext2_aops; 228 inode->i_mapping->a_ops = &ext2_aops;
245 229
246 ext2_inc_count(inode); 230 inode_inc_link_count(inode);
247 231
248 err = ext2_make_empty(inode, dir); 232 err = ext2_make_empty(inode, dir);
249 if (err) 233 if (err)
@@ -258,11 +242,11 @@ out:
258 return err; 242 return err;
259 243
260out_fail: 244out_fail:
261 ext2_dec_count(inode); 245 inode_dec_link_count(inode);
262 ext2_dec_count(inode); 246 inode_dec_link_count(inode);
263 iput(inode); 247 iput(inode);
264out_dir: 248out_dir:
265 ext2_dec_count(dir); 249 inode_dec_link_count(dir);
266 goto out; 250 goto out;
267} 251}
268 252
@@ -282,7 +266,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
282 goto out; 266 goto out;
283 267
284 inode->i_ctime = dir->i_ctime; 268 inode->i_ctime = dir->i_ctime;
285 ext2_dec_count(inode); 269 inode_dec_link_count(inode);
286 err = 0; 270 err = 0;
287out: 271out:
288 return err; 272 return err;
@@ -297,8 +281,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
297 err = ext2_unlink(dir, dentry); 281 err = ext2_unlink(dir, dentry);
298 if (!err) { 282 if (!err) {
299 inode->i_size = 0; 283 inode->i_size = 0;
300 ext2_dec_count(inode); 284 inode_dec_link_count(inode);
301 ext2_dec_count(dir); 285 inode_dec_link_count(dir);
302 } 286 }
303 } 287 }
304 return err; 288 return err;
@@ -338,41 +322,41 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
338 new_de = ext2_find_entry (new_dir, new_dentry, &new_page); 322 new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
339 if (!new_de) 323 if (!new_de)
340 goto out_dir; 324 goto out_dir;
341 ext2_inc_count(old_inode); 325 inode_inc_link_count(old_inode);
342 ext2_set_link(new_dir, new_de, new_page, old_inode); 326 ext2_set_link(new_dir, new_de, new_page, old_inode);
343 new_inode->i_ctime = CURRENT_TIME_SEC; 327 new_inode->i_ctime = CURRENT_TIME_SEC;
344 if (dir_de) 328 if (dir_de)
345 new_inode->i_nlink--; 329 new_inode->i_nlink--;
346 ext2_dec_count(new_inode); 330 inode_dec_link_count(new_inode);
347 } else { 331 } else {
348 if (dir_de) { 332 if (dir_de) {
349 err = -EMLINK; 333 err = -EMLINK;
350 if (new_dir->i_nlink >= EXT2_LINK_MAX) 334 if (new_dir->i_nlink >= EXT2_LINK_MAX)
351 goto out_dir; 335 goto out_dir;
352 } 336 }
353 ext2_inc_count(old_inode); 337 inode_inc_link_count(old_inode);
354 err = ext2_add_link(new_dentry, old_inode); 338 err = ext2_add_link(new_dentry, old_inode);
355 if (err) { 339 if (err) {
356 ext2_dec_count(old_inode); 340 inode_dec_link_count(old_inode);
357 goto out_dir; 341 goto out_dir;
358 } 342 }
359 if (dir_de) 343 if (dir_de)
360 ext2_inc_count(new_dir); 344 inode_inc_link_count(new_dir);
361 } 345 }
362 346
363 /* 347 /*
364 * Like most other Unix systems, set the ctime for inodes on a 348 * Like most other Unix systems, set the ctime for inodes on a
365 * rename. 349 * rename.
366 * ext2_dec_count() will mark the inode dirty. 350 * inode_dec_link_count() will mark the inode dirty.
367 */ 351 */
368 old_inode->i_ctime = CURRENT_TIME_SEC; 352 old_inode->i_ctime = CURRENT_TIME_SEC;
369 353
370 ext2_delete_entry (old_de, old_page); 354 ext2_delete_entry (old_de, old_page);
371 ext2_dec_count(old_inode); 355 inode_dec_link_count(old_inode);
372 356
373 if (dir_de) { 357 if (dir_de) {
374 ext2_set_link(old_inode, dir_de, dir_page, new_dir); 358 ext2_set_link(old_inode, dir_de, dir_page, new_dir);
375 ext2_dec_count(old_dir); 359 inode_dec_link_count(old_dir);
376 } 360 }
377 return 0; 361 return 0;
378 362
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index cb6f9bd658de..7e30bae174ed 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -175,7 +175,8 @@ static int init_inodecache(void)
175{ 175{
176 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache", 176 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
177 sizeof(struct ext2_inode_info), 177 sizeof(struct ext2_inode_info),
178 0, SLAB_RECLAIM_ACCOUNT, 178 0, (SLAB_RECLAIM_ACCOUNT|
179 SLAB_MEM_SPREAD),
179 init_once, NULL); 180 init_once, NULL);
180 if (ext2_inode_cachep == NULL) 181 if (ext2_inode_cachep == NULL)
181 return -ENOMEM; 182 return -ENOMEM;
@@ -210,8 +211,6 @@ static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
210 211
211 if (sbi->s_mount_opt & EXT2_MOUNT_GRPID) 212 if (sbi->s_mount_opt & EXT2_MOUNT_GRPID)
212 seq_puts(seq, ",grpid"); 213 seq_puts(seq, ",grpid");
213 else
214 seq_puts(seq, ",nogrpid");
215 214
216#if defined(CONFIG_QUOTA) 215#if defined(CONFIG_QUOTA)
217 if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA) 216 if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
@@ -258,7 +257,6 @@ static struct super_operations ext2_sops = {
258 * systems, but can be improved upon. 257 * systems, but can be improved upon.
259 * Currently only get_parent is required. 258 * Currently only get_parent is required.
260 */ 259 */
261struct dentry *ext2_get_parent(struct dentry *child);
262static struct export_operations ext2_export_ops = { 260static struct export_operations ext2_export_ops = {
263 .get_parent = ext2_get_parent, 261 .get_parent = ext2_get_parent,
264}; 262};