Loading drivers/staging/autofs/dirhash.c +49 −38 Original line number Original line Diff line number Diff line Loading @@ -48,7 +48,8 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, if (list_empty(&dh->expiry_head) || sbi->catatonic) if (list_empty(&dh->expiry_head) || sbi->catatonic) return NULL; /* No entries */ return NULL; /* No entries */ /* We keep the list sorted by last_usage and want old stuff */ /* We keep the list sorted by last_usage and want old stuff */ ent = list_entry(dh->expiry_head.next, struct autofs_dir_ent, exp); ent = list_entry(dh->expiry_head.next, struct autofs_dir_ent, exp); if (jiffies - ent->last_usage < timeout) if (jiffies - ent->last_usage < timeout) break; break; /* Move to end of list in case expiry isn't desirable */ /* Move to end of list in case expiry isn't desirable */ Loading @@ -63,14 +64,15 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, if (!path.dentry) { if (!path.dentry) { /* Should only happen in catatonic mode */ /* Should only happen in catatonic mode */ printk("autofs: dentry == NULL but inode range is directory, entry %s\n", ent->name); printk(KERN_DEBUG "autofs: dentry == NULL but inode \ range is directory, entry %s\n", ent->name); autofs_delete_usage(ent); autofs_delete_usage(ent); continue; continue; } } if (!path.dentry->d_inode) { if (!path.dentry->d_inode) { dput(path.dentry); dput(path.dentry); printk("autofs: negative dentry on expiry queue: %s\n", printk(KERN_DEBUG "autofs: negative dentry on expiry queue: %s\n", ent->name); ent->name); autofs_delete_usage(ent); autofs_delete_usage(ent); continue; continue; Loading @@ -80,14 +82,16 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, point to the mounted-on-top root. */ point to the mounted-on-top root. */ if (!S_ISDIR(path.dentry->d_inode->i_mode) || if (!S_ISDIR(path.dentry->d_inode->i_mode) || !d_mountpoint(path.dentry)) { !d_mountpoint(path.dentry)) { DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); DPRINTK(("autofs: not expirable \ (not a mounted directory): %s\n", ent->name)); continue; continue; } } path.mnt = mnt; path.mnt = mnt; path_get(&path); path_get(&path); if (!follow_down(&path)) { if (!follow_down(&path)) { path_put(&path); path_put(&path); DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); DPRINTK(("autofs: not expirable\ (not a mounted directory): %s\n", ent->name)); continue; continue; } } while (d_mountpoint(path.dentry) && follow_down(&path)) while (d_mountpoint(path.dentry) && follow_down(&path)) Loading @@ -96,27 +100,34 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, path_put(&path); path_put(&path); if (umount_ok) { if (umount_ok) { DPRINTK(("autofs: signaling expire on %s\n", ent->name)); DPRINTK(("autofs: signaling expire on %s\n", ent->name)); return ent; /* Expirable! */ return ent; /* Expirable! */ } } DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name)); DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name)); } } return NULL; /* No expirable entries */ return NULL; /* No expirable entries */ } } void autofs_initialize_hash(struct autofs_dirhash *dh) { void autofs_initialize_hash(struct autofs_dirhash *dh) { memset(&dh->h, 0, AUTOFS_HASH_SIZE*sizeof(struct autofs_dir_ent *)); memset(&dh->h, 0, AUTOFS_HASH_SIZE*sizeof(struct autofs_dir_ent *)); INIT_LIST_HEAD(&dh->expiry_head); INIT_LIST_HEAD(&dh->expiry_head); } } struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *dh, struct qstr *name) struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *dh, struct qstr *name) { { struct autofs_dir_ent *dhn; struct autofs_dir_ent *dhn; DPRINTK(("autofs_hash_lookup: hash = 0x%08x, name = ", name->hash)); DPRINTK(("autofs_hash_lookup: hash = 0x%08x, name = ", name->hash)); autofs_say(name->name, name->len); autofs_say(name->name, name->len); for ( dhn = dh->h[(unsigned) name->hash % AUTOFS_HASH_SIZE] ; dhn ; dhn = dhn->next ) { for (dhn = dh->h[(unsigned) name->hash % AUTOFS_HASH_SIZE]; dhn; dhn = dhn->next) { if (name->hash == dhn->hash && if (name->hash == dhn->hash && name->len == dhn->len && name->len == dhn->len && !memcmp(name->name, dhn->name, name->len)) !memcmp(name->name, dhn->name, name->len)) Loading Loading @@ -176,9 +187,8 @@ struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *dh, bucket = (*ptr >> 16) - 1; bucket = (*ptr >> 16) - 1; ecount = *ptr & 0xffff; ecount = *ptr & 0xffff; if ( bucket < 0 ) { if (bucket < 0) bucket = ecount = 0; bucket = ecount = 0; } DPRINTK(("autofs_hash_enum: bucket %d, entry %d\n", bucket, ecount)); DPRINTK(("autofs_hash_enum: bucket %d, entry %d\n", bucket, ecount)); Loading @@ -203,9 +213,10 @@ struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *dh, #ifdef DEBUG #ifdef DEBUG if (!ent) if (!ent) printk("autofs_hash_enum: nothing found\n"); printk(KERN_DEBUG "autofs_hash_enum: nothing found\n"); else { else { printk("autofs_hash_enum: found hash %08x, name", ent->hash); printk(KERN_DEBUG "autofs_hash_enum: found hash %08x, name", ent->hash); autofs_say(ent->name, ent->len); autofs_say(ent->name, ent->len); } } #endif #endif Loading Loading
drivers/staging/autofs/dirhash.c +49 −38 Original line number Original line Diff line number Diff line Loading @@ -48,7 +48,8 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, if (list_empty(&dh->expiry_head) || sbi->catatonic) if (list_empty(&dh->expiry_head) || sbi->catatonic) return NULL; /* No entries */ return NULL; /* No entries */ /* We keep the list sorted by last_usage and want old stuff */ /* We keep the list sorted by last_usage and want old stuff */ ent = list_entry(dh->expiry_head.next, struct autofs_dir_ent, exp); ent = list_entry(dh->expiry_head.next, struct autofs_dir_ent, exp); if (jiffies - ent->last_usage < timeout) if (jiffies - ent->last_usage < timeout) break; break; /* Move to end of list in case expiry isn't desirable */ /* Move to end of list in case expiry isn't desirable */ Loading @@ -63,14 +64,15 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, if (!path.dentry) { if (!path.dentry) { /* Should only happen in catatonic mode */ /* Should only happen in catatonic mode */ printk("autofs: dentry == NULL but inode range is directory, entry %s\n", ent->name); printk(KERN_DEBUG "autofs: dentry == NULL but inode \ range is directory, entry %s\n", ent->name); autofs_delete_usage(ent); autofs_delete_usage(ent); continue; continue; } } if (!path.dentry->d_inode) { if (!path.dentry->d_inode) { dput(path.dentry); dput(path.dentry); printk("autofs: negative dentry on expiry queue: %s\n", printk(KERN_DEBUG "autofs: negative dentry on expiry queue: %s\n", ent->name); ent->name); autofs_delete_usage(ent); autofs_delete_usage(ent); continue; continue; Loading @@ -80,14 +82,16 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, point to the mounted-on-top root. */ point to the mounted-on-top root. */ if (!S_ISDIR(path.dentry->d_inode->i_mode) || if (!S_ISDIR(path.dentry->d_inode->i_mode) || !d_mountpoint(path.dentry)) { !d_mountpoint(path.dentry)) { DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); DPRINTK(("autofs: not expirable \ (not a mounted directory): %s\n", ent->name)); continue; continue; } } path.mnt = mnt; path.mnt = mnt; path_get(&path); path_get(&path); if (!follow_down(&path)) { if (!follow_down(&path)) { path_put(&path); path_put(&path); DPRINTK(("autofs: not expirable (not a mounted directory): %s\n", ent->name)); DPRINTK(("autofs: not expirable\ (not a mounted directory): %s\n", ent->name)); continue; continue; } } while (d_mountpoint(path.dentry) && follow_down(&path)) while (d_mountpoint(path.dentry) && follow_down(&path)) Loading @@ -96,27 +100,34 @@ struct autofs_dir_ent *autofs_expire(struct super_block *sb, path_put(&path); path_put(&path); if (umount_ok) { if (umount_ok) { DPRINTK(("autofs: signaling expire on %s\n", ent->name)); DPRINTK(("autofs: signaling expire on %s\n", ent->name)); return ent; /* Expirable! */ return ent; /* Expirable! */ } } DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name)); DPRINTK(("autofs: didn't expire due to may_umount: %s\n", ent->name)); } } return NULL; /* No expirable entries */ return NULL; /* No expirable entries */ } } void autofs_initialize_hash(struct autofs_dirhash *dh) { void autofs_initialize_hash(struct autofs_dirhash *dh) { memset(&dh->h, 0, AUTOFS_HASH_SIZE*sizeof(struct autofs_dir_ent *)); memset(&dh->h, 0, AUTOFS_HASH_SIZE*sizeof(struct autofs_dir_ent *)); INIT_LIST_HEAD(&dh->expiry_head); INIT_LIST_HEAD(&dh->expiry_head); } } struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *dh, struct qstr *name) struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *dh, struct qstr *name) { { struct autofs_dir_ent *dhn; struct autofs_dir_ent *dhn; DPRINTK(("autofs_hash_lookup: hash = 0x%08x, name = ", name->hash)); DPRINTK(("autofs_hash_lookup: hash = 0x%08x, name = ", name->hash)); autofs_say(name->name, name->len); autofs_say(name->name, name->len); for ( dhn = dh->h[(unsigned) name->hash % AUTOFS_HASH_SIZE] ; dhn ; dhn = dhn->next ) { for (dhn = dh->h[(unsigned) name->hash % AUTOFS_HASH_SIZE]; dhn; dhn = dhn->next) { if (name->hash == dhn->hash && if (name->hash == dhn->hash && name->len == dhn->len && name->len == dhn->len && !memcmp(name->name, dhn->name, name->len)) !memcmp(name->name, dhn->name, name->len)) Loading Loading @@ -176,9 +187,8 @@ struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *dh, bucket = (*ptr >> 16) - 1; bucket = (*ptr >> 16) - 1; ecount = *ptr & 0xffff; ecount = *ptr & 0xffff; if ( bucket < 0 ) { if (bucket < 0) bucket = ecount = 0; bucket = ecount = 0; } DPRINTK(("autofs_hash_enum: bucket %d, entry %d\n", bucket, ecount)); DPRINTK(("autofs_hash_enum: bucket %d, entry %d\n", bucket, ecount)); Loading @@ -203,9 +213,10 @@ struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *dh, #ifdef DEBUG #ifdef DEBUG if (!ent) if (!ent) printk("autofs_hash_enum: nothing found\n"); printk(KERN_DEBUG "autofs_hash_enum: nothing found\n"); else { else { printk("autofs_hash_enum: found hash %08x, name", ent->hash); printk(KERN_DEBUG "autofs_hash_enum: found hash %08x, name", ent->hash); autofs_say(ent->name, ent->len); autofs_say(ent->name, ent->len); } } #endif #endif Loading