[PATCH] ufs: directory and page cache: install aops
authorEvgeniy Dushistov <dushistov@mail.ru>
Sun, 25 Jun 2006 12:47:21 +0000 (05:47 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 25 Jun 2006 17:01:02 +0000 (10:01 -0700)
This series of patches finished "bugs fixing" mentioned
here http://lkml.org/lkml/2006/1/31/275 .

The main bugs:
* for i in `seq 1 1000`; do touch $i; done - crash system
* mkdir create directory without "." and ".." entries

The suggested solution is work with page cache instead of straight work
with blocks.  Such solution has following advantages

* reduce code size and its complexity
* some global locks go away
* fix bugs

The most part of code is stolen from ext2, because of it has similar
directory structure.

Patches testes with UFS1 and UFS2 file systems.

This patch installs i_mapping->a_ops for directory inodes and removes some
duplicated code.

Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/ufs/inode.c
fs/ufs/namei.c

index ea2267316a72e902ccb5c494ebb9a87dde6f14b5..c28b7522c9e7924b0a6983ebc01662a64978ee8f 100644 (file)
@@ -552,6 +552,28 @@ struct address_space_operations ufs_aops = {
        .bmap = ufs_bmap
 };
 
+static void ufs_set_inode_ops(struct inode *inode)
+{
+       if (S_ISREG(inode->i_mode)) {
+               inode->i_op = &ufs_file_inode_operations;
+               inode->i_fop = &ufs_file_operations;
+               inode->i_mapping->a_ops = &ufs_aops;
+       } else if (S_ISDIR(inode->i_mode)) {
+               inode->i_op = &ufs_dir_inode_operations;
+               inode->i_fop = &ufs_dir_operations;
+               inode->i_mapping->a_ops = &ufs_aops;
+       } else if (S_ISLNK(inode->i_mode)) {
+               if (!inode->i_blocks)
+                       inode->i_op = &ufs_fast_symlink_inode_operations;
+               else {
+                       inode->i_op = &page_symlink_inode_operations;
+                       inode->i_mapping->a_ops = &ufs_aops;
+               }
+       } else
+               init_special_inode(inode, inode->i_mode,
+                                  ufs_get_inode_dev(inode->i_sb, UFS_I(inode)));
+}
+
 void ufs_read_inode (struct inode * inode)
 {
        struct ufs_inode_info *ufsi = UFS_I(inode);
@@ -626,23 +648,7 @@ void ufs_read_inode (struct inode * inode)
        }
        ufsi->i_osync = 0;
 
-       if (S_ISREG(inode->i_mode)) {
-               inode->i_op = &ufs_file_inode_operations;
-               inode->i_fop = &ufs_file_operations;
-               inode->i_mapping->a_ops = &ufs_aops;
-       } else if (S_ISDIR(inode->i_mode)) {
-               inode->i_op = &ufs_dir_inode_operations;
-               inode->i_fop = &ufs_dir_operations;
-       } else if (S_ISLNK(inode->i_mode)) {
-               if (!inode->i_blocks)
-                       inode->i_op = &ufs_fast_symlink_inode_operations;
-               else {
-                       inode->i_op = &page_symlink_inode_operations;
-                       inode->i_mapping->a_ops = &ufs_aops;
-               }
-       } else
-               init_special_inode(inode, inode->i_mode,
-                       ufs_get_inode_dev(sb, ufsi));
+       ufs_set_inode_ops(inode);
 
        brelse (bh);
 
@@ -702,23 +708,7 @@ ufs2_inode :
        }
        ufsi->i_osync = 0;
 
-       if (S_ISREG(inode->i_mode)) {
-               inode->i_op = &ufs_file_inode_operations;
-               inode->i_fop = &ufs_file_operations;
-               inode->i_mapping->a_ops = &ufs_aops;
-       } else if (S_ISDIR(inode->i_mode)) {
-               inode->i_op = &ufs_dir_inode_operations;
-               inode->i_fop = &ufs_dir_operations;
-       } else if (S_ISLNK(inode->i_mode)) {
-               if (!inode->i_blocks)
-                       inode->i_op = &ufs_fast_symlink_inode_operations;
-               else {
-                       inode->i_op = &page_symlink_inode_operations;
-                       inode->i_mapping->a_ops = &ufs_aops;
-               }
-       } else   /* TODO  : here ...*/
-               init_special_inode(inode, inode->i_mode,
-                       ufs_get_inode_dev(sb, ufsi));
+       ufs_set_inode_ops(inode);
 
        brelse(bh);
 
index 8d5f98a01c7484010803d732124398f9124b30e7..51f7027003083838bfa70c543cd45058ffbec065 100644 (file)
@@ -205,6 +205,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
 
        inode->i_op = &ufs_dir_inode_operations;
        inode->i_fop = &ufs_dir_operations;
+       inode->i_mapping->a_ops = &ufs_aops;
 
        inode_inc_link_count(inode);