summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Viro <viro@www.linux.org.uk>2004-03-17 21:24:02 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-03-17 21:24:02 -0800
commit772fd530badfe14a708a1f4df26b19bfbbb6785a (patch)
tree2ce9f683bb9edefbcef9bbfb3b7676f0bdd3e1d4
parentb5b83baea0b32c53a49ed5a009f06666fcd44b03 (diff)
[PATCH] hpfs: hpfs iget locking cleanup
Killed the nightmares in hpfs iget handling. Since in some (fairly frequent) cases hpfs_read_inode() could avoid any IO (basically, lookup hitting a native HPFS regular file can get all data from directory entry) hpfs had a flag passed to that sucker. Said flag had been protected by a semaphore lookalike made out of spit and duct-tape and callers of iget looked like hpfs_lock_iget(sb, flag); result = iget(sb, ino); hpfs_unlock_iget(sb); Since now we are calling hpfs_read_inode() directly (note that calling it without hpfs_lock_iget() would simply break) we can forget all that crap and get rid of the flag - caller knows what it wants to call. BTW, that had killed one of the last sleep_on() users in fs/*/*.
-rw-r--r--fs/hpfs/buffer.c18
-rw-r--r--fs/hpfs/dir.c16
-rw-r--r--fs/hpfs/hpfs_fn.h2
-rw-r--r--fs/hpfs/inode.c16
-rw-r--r--fs/hpfs/super.c10
-rw-r--r--include/linux/hpfs_fs_sb.h5
6 files changed, 15 insertions, 52 deletions
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c
index 3d11f50d5ea1..65f7e2f1667e 100644
--- a/fs/hpfs/buffer.c
+++ b/fs/hpfs/buffer.c
@@ -26,24 +26,6 @@ void hpfs_unlock_creation(struct super_block *s)
up(&hpfs_sb(s)->hpfs_creation_de);
}
-void hpfs_lock_iget(struct super_block *s, int mode)
-{
-#ifdef DEBUG_LOCKS
- printk("lock iget\n");
-#endif
- while (hpfs_sb(s)->sb_rd_inode) sleep_on(&hpfs_sb(s)->sb_iget_q);
- hpfs_sb(s)->sb_rd_inode = mode;
-}
-
-void hpfs_unlock_iget(struct super_block *s)
-{
-#ifdef DEBUG_LOCKS
- printk("unlock iget\n");
-#endif
- hpfs_sb(s)->sb_rd_inode = 0;
- wake_up(&hpfs_sb(s)->sb_iget_q);
-}
-
void hpfs_lock_inode(struct inode *i)
{
if (i) {
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index bc998cab8346..4a0eb194c138 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -243,20 +243,28 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
* Go find or make an inode.
*/
- hpfs_lock_iget(dir->i_sb, de->directory || (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas) ? 1 : 2);
result = iget_locked(dir->i_sb, ino);
if (!result) {
- hpfs_unlock_iget(dir->i_sb);
hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
goto bail1;
}
if (result->i_state & I_NEW) {
- hpfs_read_inode(result);
+ hpfs_init_inode(result);
+ if (de->directory)
+ hpfs_read_inode(result);
+ else if (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas)
+ hpfs_read_inode(result);
+ else {
+ result->i_mode |= S_IFREG;
+ result->i_mode &= ~0111;
+ result->i_op = &hpfs_file_iops;
+ result->i_fop = &hpfs_file_ops;
+ result->i_nlink = 1;
+ }
unlock_new_inode(result);
}
hpfs_result = hpfs_i(result);
if (!de->directory) hpfs_result->i_parent_dir = dir->i_ino;
- hpfs_unlock_iget(dir->i_sb);
hpfs_decide_conv(result, (char *)name, len);
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 4c697097039b..34b2dd5f811a 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -192,8 +192,6 @@ void hpfs_remove_fnode(struct super_block *, fnode_secno fno);
void hpfs_lock_creation(struct super_block *);
void hpfs_unlock_creation(struct super_block *);
-void hpfs_lock_iget(struct super_block *, int);
-void hpfs_unlock_iget(struct super_block *);
void hpfs_lock_inode(struct inode *);
void hpfs_unlock_inode(struct inode *);
void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int);
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 5006bfde167c..cc51651baa5d 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -98,18 +98,6 @@ void hpfs_read_inode(struct inode *i)
unsigned char *ea;
int ea_size;
- hpfs_init_inode(i);
-
- if (!hpfs_sb(i->i_sb)->sb_rd_inode)
- hpfs_error(i->i_sb, "read_inode: sb_rd_inode == 0");
- if (hpfs_sb(i->i_sb)->sb_rd_inode == 2) {
- i->i_mode |= S_IFREG;
- i->i_mode &= ~0111;
- i->i_op = &hpfs_file_iops;
- i->i_fop = &hpfs_file_ops;
- i->i_nlink = 1;
- return;
- }
if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) {
/*i->i_mode |= S_IFREG;
i->i_mode &= ~0111;
@@ -248,21 +236,19 @@ void hpfs_write_inode(struct inode *i)
kfree(hpfs_inode->i_rddir_off);
hpfs_inode->i_rddir_off = NULL;
}
- hpfs_lock_iget(i->i_sb, 1);
parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
if (parent) {
hpfs_inode->i_dirty = 0;
if (parent->i_state & I_NEW) {
+ hpfs_init_inode(parent);
hpfs_read_inode(parent);
unlock_new_inode(parent);
}
- hpfs_unlock_iget(i->i_sb);
hpfs_lock_inode(parent);
hpfs_write_inode_nolock(i);
hpfs_unlock_inode(parent);
iput(parent);
} else {
- hpfs_unlock_iget(i->i_sb);
mark_inode_dirty(i);
}
}
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 2fdc079c1e8c..ff630e40b590 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -211,7 +211,6 @@ static struct super_operations hpfs_sops =
{
.alloc_inode = hpfs_alloc_inode,
.destroy_inode = hpfs_destroy_inode,
- .read_inode = hpfs_read_inode,
.delete_inode = hpfs_delete_inode,
.put_super = hpfs_put_super,
.statfs = hpfs_statfs,
@@ -470,9 +469,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
sbi->sb_bmp_dir = NULL;
sbi->sb_cp_table = NULL;
- sbi->sb_rd_inode = 0;
init_MUTEX(&sbi->hpfs_creation_de);
- init_waitqueue_head(&sbi->sb_iget_q);
uid = current->uid;
gid = current->gid;
@@ -613,15 +610,12 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
brelse(bh1);
brelse(bh0);
- hpfs_lock_iget(s, 1);
root = iget_locked(s, sbi->sb_root);
- if (!root) {
- hpfs_unlock_iget(s);
+ if (!root)
goto bail0;
- }
+ hpfs_init_inode(root);
hpfs_read_inode(root);
unlock_new_inode(root);
- hpfs_unlock_iget(s);
s->s_root = d_alloc_root(root);
if (!s->s_root) {
iput(root);
diff --git a/include/linux/hpfs_fs_sb.h b/include/linux/hpfs_fs_sb.h
index c6355adaf6f1..6eceb9539c90 100644
--- a/include/linux/hpfs_fs_sb.h
+++ b/include/linux/hpfs_fs_sb.h
@@ -20,11 +20,6 @@ struct hpfs_sb_info {
unsigned sb_lowercase : 1; /* downcase filenames hackery */
unsigned sb_was_error : 1; /* there was an error, set dirty flag */
unsigned sb_chkdsk : 2; /* chkdsk: 0-no, 1-on errs, 2-allways */
- unsigned sb_rd_fnode : 2; /* read fnode 0-no 1-dirs 2-all */
- unsigned sb_rd_inode : 2; /* lookup tells read_inode: 1-read fnode
- 2-don't read fnode, file
- 3-don't read fnode, direcotry */
- wait_queue_head_t sb_iget_q;
unsigned char *sb_cp_table; /* code page tables: */
/* 128 bytes uppercasing table & */
/* 128 bytes lowercasing table */