Skip to content

Commit

Permalink
hfs: switch to ->iterate_shared()
Browse files Browse the repository at this point in the history
exact parallel of hfsplus analogue

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed May 13, 2016
1 parent 323ee8f commit 9717a91
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions fs/hfs/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, struct qstr *str)
}
}

/* we only need to take spinlock for exclusion with ->release() */
spin_lock(&HFS_I(dir)->open_dir_lock);
list_for_each_entry(rd, &HFS_I(dir)->open_dir_list, list) {
if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0)
rd->file->f_pos--;
}
spin_unlock(&HFS_I(dir)->open_dir_lock);

res = hfs_brec_remove(&fd);
if (res)
Expand Down
12 changes: 9 additions & 3 deletions fs/hfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,14 @@ static int hfs_readdir(struct file *file, struct dir_context *ctx)
}
file->private_data = rd;
rd->file = file;
spin_lock(&HFS_I(inode)->open_dir_lock);
list_add(&rd->list, &HFS_I(inode)->open_dir_list);
spin_unlock(&HFS_I(inode)->open_dir_lock);
}
/*
* Can be done after the list insertion; exclusion with
* hfs_delete_cat() is provided by directory lock.
*/
memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key));
out:
hfs_find_exit(&fd);
Expand All @@ -173,9 +179,9 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
{
struct hfs_readdir_data *rd = file->private_data;
if (rd) {
inode_lock(inode);
spin_lock(&HFS_I(inode)->open_dir_lock);
list_del(&rd->list);
inode_unlock(inode);
spin_unlock(&HFS_I(inode)->open_dir_lock);
kfree(rd);
}
return 0;
Expand Down Expand Up @@ -303,7 +309,7 @@ static int hfs_rename(struct inode *old_dir, struct dentry *old_dentry,

const struct file_operations hfs_dir_operations = {
.read = generic_read_dir,
.iterate = hfs_readdir,
.iterate_shared = hfs_readdir,
.llseek = generic_file_llseek,
.release = hfs_dir_release,
};
Expand Down
1 change: 1 addition & 0 deletions fs/hfs/hfs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct hfs_inode_info {
struct hfs_cat_key cat_key;

struct list_head open_dir_list;
spinlock_t open_dir_lock;
struct inode *rsrc_inode;

struct mutex extents_lock;
Expand Down
2 changes: 2 additions & 0 deletions fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode)

mutex_init(&HFS_I(inode)->extents_lock);
INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
spin_lock_init(&HFS_I(inode)->open_dir_lock);
hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name);
inode->i_ino = HFS_SB(sb)->next_id++;
inode->i_mode = mode;
Expand Down Expand Up @@ -318,6 +319,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
HFS_I(inode)->rsrc_inode = NULL;
mutex_init(&HFS_I(inode)->extents_lock);
INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
spin_lock_init(&HFS_I(inode)->open_dir_lock);

/* Initialize the inode */
inode->i_uid = hsb->s_uid;
Expand Down

0 comments on commit 9717a91

Please sign in to comment.