Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hfs: switch to ->iterate_shared()

exact parallel of hfsplus analogue

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 9717a91b 323ee8fc

+15 -3
+3
fs/hfs/catalog.c
··· 240 240 } 241 241 } 242 242 243 + /* we only need to take spinlock for exclusion with ->release() */ 244 + spin_lock(&HFS_I(dir)->open_dir_lock); 243 245 list_for_each_entry(rd, &HFS_I(dir)->open_dir_list, list) { 244 246 if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) 245 247 rd->file->f_pos--; 246 248 } 249 + spin_unlock(&HFS_I(dir)->open_dir_lock); 247 250 248 251 res = hfs_brec_remove(&fd); 249 252 if (res)
+9 -3
fs/hfs/dir.c
··· 161 161 } 162 162 file->private_data = rd; 163 163 rd->file = file; 164 + spin_lock(&HFS_I(inode)->open_dir_lock); 164 165 list_add(&rd->list, &HFS_I(inode)->open_dir_list); 166 + spin_unlock(&HFS_I(inode)->open_dir_lock); 165 167 } 168 + /* 169 + * Can be done after the list insertion; exclusion with 170 + * hfs_delete_cat() is provided by directory lock. 171 + */ 166 172 memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key)); 167 173 out: 168 174 hfs_find_exit(&fd); ··· 179 173 { 180 174 struct hfs_readdir_data *rd = file->private_data; 181 175 if (rd) { 182 - inode_lock(inode); 176 + spin_lock(&HFS_I(inode)->open_dir_lock); 183 177 list_del(&rd->list); 184 - inode_unlock(inode); 178 + spin_unlock(&HFS_I(inode)->open_dir_lock); 185 179 kfree(rd); 186 180 } 187 181 return 0; ··· 309 303 310 304 const struct file_operations hfs_dir_operations = { 311 305 .read = generic_read_dir, 312 - .iterate = hfs_readdir, 306 + .iterate_shared = hfs_readdir, 313 307 .llseek = generic_file_llseek, 314 308 .release = hfs_dir_release, 315 309 };
+1
fs/hfs/hfs_fs.h
··· 69 69 struct hfs_cat_key cat_key; 70 70 71 71 struct list_head open_dir_list; 72 + spinlock_t open_dir_lock; 72 73 struct inode *rsrc_inode; 73 74 74 75 struct mutex extents_lock;
+2
fs/hfs/inode.c
··· 187 187 188 188 mutex_init(&HFS_I(inode)->extents_lock); 189 189 INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); 190 + spin_lock_init(&HFS_I(inode)->open_dir_lock); 190 191 hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name); 191 192 inode->i_ino = HFS_SB(sb)->next_id++; 192 193 inode->i_mode = mode; ··· 319 318 HFS_I(inode)->rsrc_inode = NULL; 320 319 mutex_init(&HFS_I(inode)->extents_lock); 321 320 INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list); 321 + spin_lock_init(&HFS_I(inode)->open_dir_lock); 322 322 323 323 /* Initialize the inode */ 324 324 inode->i_uid = hsb->s_uid;