dm.c (c217649bf2d60ac119afd71d938278cffd55962b) | dm.c (4a1aeb98297e17f4e0a8cdda919e63bf528b2e5d) |
---|---|
1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm.h" --- 18 unchanged lines hidden (view full) --- 27 28/* 29 * Cookies are numeric values sent with CHANGE and REMOVE 30 * uevents while resuming, removing or renaming the device. 31 */ 32#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 33#define DM_COOKIE_LENGTH 24 34 | 1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm.h" --- 18 unchanged lines hidden (view full) --- 27 28/* 29 * Cookies are numeric values sent with CHANGE and REMOVE 30 * uevents while resuming, removing or renaming the device. 31 */ 32#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 33#define DM_COOKIE_LENGTH 24 34 |
35static DEFINE_MUTEX(dm_mutex); | |
36static const char *_name = DM_NAME; 37 38static unsigned int major = 0; 39static unsigned int _major = 0; 40 41static DEFINE_SPINLOCK(_minor_lock); 42/* 43 * For bio-based dm. --- 279 unchanged lines hidden (view full) --- 323{ 324 return test_bit(DMF_DELETING, &md->flags); 325} 326 327static int dm_blk_open(struct block_device *bdev, fmode_t mode) 328{ 329 struct mapped_device *md; 330 | 35static const char *_name = DM_NAME; 36 37static unsigned int major = 0; 38static unsigned int _major = 0; 39 40static DEFINE_SPINLOCK(_minor_lock); 41/* 42 * For bio-based dm. --- 279 unchanged lines hidden (view full) --- 322{ 323 return test_bit(DMF_DELETING, &md->flags); 324} 325 326static int dm_blk_open(struct block_device *bdev, fmode_t mode) 327{ 328 struct mapped_device *md; 329 |
331 mutex_lock(&dm_mutex); | |
332 spin_lock(&_minor_lock); 333 334 md = bdev->bd_disk->private_data; 335 if (!md) 336 goto out; 337 338 if (test_bit(DMF_FREEING, &md->flags) || 339 dm_deleting_md(md)) { 340 md = NULL; 341 goto out; 342 } 343 344 dm_get(md); 345 atomic_inc(&md->open_count); 346 347out: 348 spin_unlock(&_minor_lock); | 330 spin_lock(&_minor_lock); 331 332 md = bdev->bd_disk->private_data; 333 if (!md) 334 goto out; 335 336 if (test_bit(DMF_FREEING, &md->flags) || 337 dm_deleting_md(md)) { 338 md = NULL; 339 goto out; 340 } 341 342 dm_get(md); 343 atomic_inc(&md->open_count); 344 345out: 346 spin_unlock(&_minor_lock); |
349 mutex_unlock(&dm_mutex); | |
350 351 return md ? 0 : -ENXIO; 352} 353 354static int dm_blk_close(struct gendisk *disk, fmode_t mode) 355{ 356 struct mapped_device *md = disk->private_data; 357 | 347 348 return md ? 0 : -ENXIO; 349} 350 351static int dm_blk_close(struct gendisk *disk, fmode_t mode) 352{ 353 struct mapped_device *md = disk->private_data; 354 |
358 mutex_lock(&dm_mutex); | 355 spin_lock(&_minor_lock); 356 |
359 atomic_dec(&md->open_count); 360 dm_put(md); | 357 atomic_dec(&md->open_count); 358 dm_put(md); |
361 mutex_unlock(&dm_mutex); | |
362 | 359 |
360 spin_unlock(&_minor_lock); 361 |
|
363 return 0; 364} 365 366int dm_open_count(struct mapped_device *md) 367{ 368 return atomic_read(&md->open_count); 369} 370 --- 2349 unchanged lines hidden --- | 362 return 0; 363} 364 365int dm_open_count(struct mapped_device *md) 366{ 367 return atomic_read(&md->open_count); 368} 369 --- 2349 unchanged lines hidden --- |