[PATCH] more autofs4 fixes for 2.3.99-pre5

From: Jeremy Fitzhardinge (jeremy@goop.org)
Date: Thu Apr 13 2000 - 19:53:08 EST


Here's another set of fixes which incorporates the patch this morning
(ie, its against pristine 2.3.99pre5).

This also fixes various bugs someone introduced into the expiry
busyness test in -pre4, and it completely gets rid of the inode "hash".
Inodes are never hashed in the kernel's cache, and are always hanging off
dentries. This simplifies memory allocation and freeing somewhat, as
well as being much cleaner.

        J

diff -X ../diffexcl -Nur 2.3/fs/autofs4/Makefile abulafia-2.3/fs/autofs4/Makefil
e
--- 2.3/fs/autofs4/Makefile Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/Makefile Thu Apr 13 16:29:23 2000
@@ -5,7 +5,7 @@
 #
 
 O_TARGET := autofs4.o
-O_OBJS := inohash.o init.o inode.o root.o symlink.o waitq.o expire.o
+O_OBJS := init.o inode.o root.o symlink.o waitq.o expire.o
 
 M_OBJS := $(O_TARGET)
 
diff -X ../diffexcl -Nur 2.3/fs/autofs4/autofs_i.h abulafia-2.3/fs/autofs4/autof
s_i.h
--- 2.3/fs/autofs4/autofs_i.h Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/autofs_i.h Thu Apr 13 17:11:58 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- ------------------------------------------------------- *
+/* -*- c -*- ------------------------------------------------------------- *
  *
  * linux/fs/autofs/autofs_i.h
  *
@@ -57,10 +57,8 @@
         int flags;
 
         struct autofs_sb_info *sbi;
- struct list_head ino_hash;
         unsigned long last_used;
 
- ino_t ino;
         mode_t mode;
         size_t size;
 
@@ -72,10 +70,6 @@
 
 #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */
 
-struct autofs_inohash {
- struct list_head head;
-};
-
 struct autofs_wait_queue {
         wait_queue_head_t queue;
         struct autofs_wait_queue *next;
@@ -89,9 +83,6 @@
         int wait_ctr;
 };
 
-#define AUTOFS_ROOT_INO 1
-#define AUTOFS_FIRST_INO 2
-
 #define AUTOFS_SBI_MAGIC 0x6d4a556d
 
 struct autofs_sb_info {
@@ -101,10 +92,8 @@
         int catatonic;
         int version;
         unsigned long exp_timeout;
- ino_t next_ino;
         struct super_block *sb;
         struct autofs_wait_queue *queues; /* Wait queue pointer */
- struct autofs_inohash ihash;
 };
 
 static inline struct autofs_sb_info *autofs4_sbi(struct super_block *sb)
@@ -134,13 +123,7 @@
                 (inf != NULL && inf->flags & AUTOFS_INF_EXPIRING);
 }
 
-/* Inode hash operations */
-void autofs4_init_ihash(struct autofs_inohash *);
-void autofs4_ihash_insert(struct autofs_inohash *ih, struct autofs_info *ino);
-void autofs4_ihash_delete(struct autofs_info *ino);
-void autofs4_ihash_nuke(struct autofs_inohash *ih);
-struct autofs_info *autofs4_ihash_find(struct autofs_inohash *ih, ino_t ino);
-
+struct inode *autofs4_get_inode(struct super_block *, struct autofs_info *);
 struct autofs_info *autofs4_init_inf(struct autofs_sb_info *, mode_t mode);
 void autofs4_free_ino(struct autofs_info *);
 
diff -X ../diffexcl -Nur 2.3/fs/autofs4/expire.c abulafia-2.3/fs/autofs4/expire.
c
--- 2.3/fs/autofs4/expire.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/expire.c Thu Apr 13 17:09:44 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/expire.c
  *
@@ -46,8 +46,9 @@
                 count--;
         }
 
- /* Mountpoints don't count */
- if (d_mountpoint(root)) {
+ /* Mountpoints don't count (either mountee or mounter) */
+ if (d_mountpoint(root) ||
+ root != root->d_covers) {
                 DPRINTK(("is_tree_busy: mountpoint\n"));
                 count--;
         }
@@ -75,9 +76,11 @@
                 /* Decrement count for unused children */
                 count += (dentry->d_count - 1);
 
- /* Mountpoints don't count */
- if (d_mountpoint(dentry)) {
- DPRINTK(("is_tree_busy: mountpoint\n"));
+ /* Mountpoints don't count (either mountee or mounter) */
+ if (d_mountpoint(dentry) ||
+ dentry != dentry->d_covers) {
+ DPRINTK(("is_tree_busy: mountpoint dentry=%p covers=%p mounts=%p\n",
+ dentry, dentry->d_covers, dentry->d_mounts));
                         adj++;
                 }
 
diff -X ../diffexcl -Nur 2.3/fs/autofs4/init.c abulafia-2.3/fs/autofs4/init.c
--- 2.3/fs/autofs4/init.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/init.c Wed Apr 12 23:09:29 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/init.c
  *
diff -X ../diffexcl -Nur 2.3/fs/autofs4/inode.c abulafia-2.3/fs/autofs4/inode.c
--- 2.3/fs/autofs4/inode.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/inode.c Thu Apr 13 16:43:43 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/inode.c
  *
@@ -41,7 +41,6 @@
                 return NULL;
 
         ino->flags = 0;
- ino->ino = sbi->next_ino++;
         ino->mode = mode;
         ino->inode = NULL;
         ino->dentry = NULL;
@@ -50,7 +49,6 @@
         ino->last_used = jiffies;
 
         ino->sbi = sbi;
- INIT_LIST_HEAD(&ino->ino_hash);
 
         if (reinit && ino->free)
                 (ino->free)(ino);
@@ -67,7 +65,6 @@
 
 void autofs4_free_ino(struct autofs_info *ino)
 {
- autofs4_ihash_delete(ino);
         if (ino->dentry) {
                 ino->dentry->d_fsdata = NULL;
                 if (ino->dentry->d_inode)
@@ -79,18 +76,6 @@
         kfree(ino);
 }
 
-/*
- * Dummy functions - do we ever actually want to do
- * something here?
- */
-static void autofs4_put_inode(struct inode *inode)
-{
-}
-
-static void autofs4_clear_inode(struct inode *inode)
-{
-}
-
 static void autofs4_put_super(struct super_block *sb)
 {
         struct autofs_sb_info *sbi = autofs4_sbi(sb);
@@ -105,26 +90,11 @@
         DPRINTK(("autofs: shutting down\n"));
 }
 
-static void autofs4_umount_begin(struct super_block *sb)
-{
- struct autofs_sb_info *sbi = autofs4_sbi(sb);
-
- if (!sbi->catatonic)
- autofs4_catatonic_mode(sbi);
-}
-
 static int autofs4_statfs(struct super_block *sb, struct statfs *buf);
-static void autofs4_read_inode(struct inode *inode);
-static void autofs4_write_inode(struct inode *inode);
 
 static struct super_operations autofs4_sops = {
- read_inode: autofs4_read_inode,
- write_inode: autofs4_write_inode,
- put_inode: autofs4_put_inode,
- clear_inode: autofs4_clear_inode,
         put_super: autofs4_put_super,
         statfs: autofs4_statfs,
- umount_begin: autofs4_umount_begin,
 };
 
 static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
@@ -200,8 +170,6 @@
         if (!ino)
                 return NULL;
 
- ino->ino = AUTOFS_ROOT_INO;
-
         return ino;
 }
 
@@ -233,9 +201,7 @@
         sbi->oz_pgrp = current->pgrp;
         sbi->sb = s;
         sbi->version = 0;
- autofs4_init_ihash(&sbi->ihash);
         sbi->queues = NULL;
- sbi->next_ino = AUTOFS_FIRST_INO;
         s->s_blocksize = 1024;
         s->s_blocksize_bits = 10;
         s->s_magic = AUTOFS_SUPER_MAGIC;
@@ -245,9 +211,9 @@
         /*
          * Get the root inode and dentry, but defer checking for errors.
          */
- autofs4_ihash_insert(&sbi->ihash, autofs4_mkroot(sbi));
-
- root_inode = iget(s, AUTOFS_ROOT_INO);
+ root_inode = autofs4_get_inode(s, autofs4_mkroot(sbi));
+ root_inode->i_op = &autofs4_root_inode_operations;
+ root_inode->i_fop = &autofs4_root_operations;
         root = d_alloc_root(root_inode);
         pipe = NULL;
 
@@ -358,48 +324,40 @@
         return 0;
 }
 
-static void autofs4_read_inode(struct inode *inode)
+struct inode *autofs4_get_inode(struct super_block *sb,
+ struct autofs_info *inf)
 {
- struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
- struct autofs_info *inf;
-
- inf = autofs4_ihash_find(&sbi->ihash, inode->i_ino);
+ struct inode *inode = get_empty_inode();
 
- if (inf == NULL || inf->inode != NULL)
- return;
+ if (inode == NULL)
+ return NULL;
 
+ inf->inode = inode;
+ inode->i_sb = sb;
+ inode->i_dev = sb->s_dev;
         inode->i_mode = inf->mode;
- inode->i_mtime = inode->i_ctime = inode->i_atime = CURRENT_TIME;
- inode->i_size = inf->size;
-
- inode->i_blocks = 0;
- inode->i_blksize = 0;
- inode->i_nlink = 1;
-
- if (inode->i_sb->s_root) {
- inode->i_uid = inode->i_sb->s_root->d_inode->i_uid;
- inode->i_gid = inode->i_sb->s_root->d_inode->i_gid;
+ if (sb->s_root) {
+ inode->i_uid = sb->s_root->d_inode->i_uid;
+ inode->i_gid = sb->s_root->d_inode->i_gid;
         } else {
                 inode->i_uid = 0;
                 inode->i_gid = 0;
         }
-
- inf->inode = inode;
+ inode->i_size = 0;
+ inode->i_blksize = PAGE_CACHE_SIZE;
+ inode->i_blocks = 0;
+ inode->i_rdev = 0;
+ inode->i_nlink = 1;
+ inode->i_op = NULL;
+ inode->i_fop = NULL;
+ inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
 
         if (S_ISDIR(inf->mode)) {
                 inode->i_nlink = 2;
- if (inode->i_ino == AUTOFS_ROOT_INO) {
- inode->i_op = &autofs4_root_inode_operations;
- inode->i_fop = &autofs4_root_operations;
- } else {
- inode->i_op = &autofs4_dir_inode_operations;
- inode->i_fop = &autofs4_dir_operations;
- }
- } else if (S_ISLNK(inf->mode)) {
+ inode->i_op = &autofs4_dir_inode_operations;
+ inode->i_fop = &autofs4_dir_operations;
+ } else if (S_ISLNK(inf->mode))
                 inode->i_op = &autofs4_symlink_inode_operations;
- }
-}
 
-static void autofs4_write_inode(struct inode *inode)
-{
+ return inode;
 }
diff -X ../diffexcl -Nur 2.3/fs/autofs4/inohash.c abulafia-2.3/fs/autofs4/inohas
h.c
--- 2.3/fs/autofs4/inohash.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/inohash.c Wed Dec 31 16:00:00 1969
@@ -1,68 +0,0 @@
-/*
- * "inohash" is a misnomer. Inodes are just stored in a single list,
- * since this code is only ever asked for the most recently inserted
- * inode.
- *
- * Copyright 1999 Jeremy Fitzhardinge <jeremy@goop.org>
- */
-
-#include "autofs_i.h"
-
-void autofs4_init_ihash(struct autofs_inohash *ih)
-{
- INIT_LIST_HEAD(&ih->head);
-}
-
-void autofs4_ihash_insert(struct autofs_inohash *ih,
- struct autofs_info *ino)
-{
- DPRINTK(("autofs_ihash_insert: adding ino %ld\n", ino->ino));
-
- list_add(&ino->ino_hash, &ih->head);
-}
-
-void autofs4_ihash_delete(struct autofs_info *inf)
-{
- DPRINTK(("autofs_ihash_delete: deleting ino %ld\n", inf->ino));
-
- if (!list_empty(&inf->ino_hash))
- list_del(&inf->ino_hash);
-}
-
-struct autofs_info *autofs4_ihash_find(struct autofs_inohash *ih,
- ino_t inum)
-{
- struct list_head *tmp;
-
- for(tmp = ih->head.next;
- tmp != &ih->head;
- tmp = tmp->next) {
- struct autofs_info *ino = list_entry(tmp, struct autofs_info, ino_hash);
- if (ino->ino == inum) {
- DPRINTK(("autofs_ihash_find: found %ld -> %p\n",
- inum, ino));
- return ino;
- }
- }
- DPRINTK(("autofs_ihash_find: didn't find %ld\n", inum));
- return NULL;
-}
-
-void autofs4_ihash_nuke(struct autofs_inohash *ih)
-{
- struct list_head *tmp = ih->head.next;
- struct list_head *next;
-
- for(; tmp != &ih->head; tmp = next) {
- struct autofs_info *ino;
-
- next = tmp->next;
-
- ino = list_entry(tmp, struct autofs_info, ino_hash);
-
- DPRINTK(("autofs_ihash_nuke: nuking %ld\n", ino->ino));
- autofs4_free_ino(ino);
- }
- INIT_LIST_HEAD(&ih->head);
-}
-
diff -X ../diffexcl -Nur 2.3/fs/autofs4/root.c abulafia-2.3/fs/autofs4/root.c
--- 2.3/fs/autofs4/root.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/root.c Thu Apr 13 16:49:09 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/root.c
  *
@@ -175,7 +175,7 @@
                         /* Return a negative dentry, but leave it "pending" */
                         return 1;
                 }
- status = autofs4_wait(sbi, &dentry->d_name, NFY_MOUNT);
+ /* status = autofs4_wait(sbi, &dentry->d_name, NFY_MOUNT); */
         }
 
         /* If this is an unused directory that isn't a mount point,
@@ -230,7 +230,7 @@
             list_empty(&dentry->d_subdirs)) {
                 DPRINTK(("autofs_root_revalidate: dentry=%p %.*s, emptydir\n",
                          dentry, dentry->d_name.len, dentry->d_name.name));
- if (autofs4_oz_mode(sbi))
+ if (oz_mode)
                         return 1;
                 else
                         return try_to_fill_dentry(dentry, dir->i_sb, sbi);
@@ -323,12 +323,10 @@
          *
          * We need to do this before we release the directory semaphore.
          */
- if (dir->i_ino == AUTOFS_ROOT_INO)
- dentry->d_op = &autofs4_root_dentry_operations;
- else
- dentry->d_op = &autofs4_dentry_operations;
+ dentry->d_op = &autofs4_root_dentry_operations;
 
- dentry->d_flags |= DCACHE_AUTOFS_PENDING;
+ if (!oz_mode)
+ dentry->d_flags |= DCACHE_AUTOFS_PENDING;
         dentry->d_fsdata = NULL;
         d_add(dentry, NULL);
 
@@ -397,11 +395,10 @@
 
         strcpy(cp, symname);
 
- autofs4_ihash_insert(&sbi->ihash, ino);
- inode = iget(dir->i_sb,ino->ino);
+ inode = autofs4_get_inode(dir->i_sb, ino);
         d_instantiate(dentry, inode);
 
- if (dir->i_ino == AUTOFS_ROOT_INO)
+ if (dir == dir->i_sb->s_root->d_inode)
                 dentry->d_op = &autofs4_root_dentry_operations;
         else
                 dentry->d_op = &autofs4_dentry_operations;
@@ -520,12 +517,10 @@
         if (ino == NULL)
                 return -ENOSPC;
 
- autofs4_ihash_insert(&sbi->ihash, ino);
-
- inode = iget(dir->i_sb, ino->ino);
+ inode = autofs4_get_inode(dir->i_sb, ino);
         d_instantiate(dentry, inode);
 
- if (dir->i_ino == AUTOFS_ROOT_INO)
+ if (dir == dir->i_sb->s_root->d_inode)
                 dentry->d_op = &autofs4_root_dentry_operations;
         else
                 dentry->d_op = &autofs4_dentry_operations;
diff -X ../diffexcl -Nur 2.3/fs/autofs4/symlink.c abulafia-2.3/fs/autofs4/symlin
k.c
--- 2.3/fs/autofs4/symlink.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/symlink.c Wed Apr 12 23:09:30 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/symlink.c
  *
diff -X ../diffexcl -Nur 2.3/fs/autofs4/waitq.c abulafia-2.3/fs/autofs4/waitq.c
--- 2.3/fs/autofs4/waitq.c Wed Apr 12 23:05:48 2000
+++ linux/fs/autofs4/waitq.c Thu Apr 13 16:34:13 2000
@@ -1,4 +1,4 @@
-/* -*- linux-c -*- --------------------------------------------------------- *
+/* -*- c -*- --------------------------------------------------------------- *
  *
  * linux/fs/autofs/waitq.c
  *
@@ -45,7 +45,6 @@
                 sbi->pipe = NULL;
         }
 
- autofs4_ihash_nuke(&sbi->ihash);
         shrink_dcache_sb(sbi->sb);
 }
 

End of MIME message

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:23 EST