On Sat, Mar 1, 2008 at 3:39 PM, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote: > In fs/super.c, I saw a down_read() without a matching up_read() as shown below: > > /** > * get_super - get the superblock of a device > * @bdev: device to get the superblock for > * > * Scans the superblock list and finds the superblock of the file system > * mounted on the device given. %NULL is returned if no match is found. > */ > > struct super_block * get_super(struct block_device *bdev) > { > struct super_block *sb; > > if (!bdev) > return NULL; > > spin_lock(&sb_lock); > rescan: > list_for_each_entry(sb, &super_blocks, s_list) { > if (sb->s_bdev == bdev) { > sb->s_count++; > spin_unlock(&sb_lock); > down_read(&sb->s_umount); > if (sb->s_root) > return sb; > up_read(&sb->s_umount); > /* restart only when sb is no longer on the list */ > spin_lock(&sb_lock); > if (__put_super_and_need_restart(sb)) > goto rescan; > } > } > spin_unlock(&sb_lock); > return NULL; > } > > EXPORT_SYMBOL(get_super); > > Neither did the get_super() caller remember and correct the semaphore > either. Is this a problem? > > Thanks. > Thanks to Al Viro for the education, the answer is that get_super and drop_super worked as pair, so no issue with the semaphore usage: 1476 int __invalidate_device(struct block_device *bdev) 1477 { 1478 struct super_block *sb = get_super(bdev); 1479 int res = 0; 1480 1481 if (sb) { 1482 /* 1483 * no need to lock the super, get_super holds the 1484 * read mutex so the filesystem cannot go away 1485 * under us (->put_super runs with the write lock 1486 * hold). 1487 */ 1488 shrink_dcache_sb(sb); 1489 res = invalidate_inodes(sb); 1490 drop_super(sb); 1491 } 1492 invalidate_bdev(bdev); 1493 return res; 1494 } -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ