linux/fs/block_dev.c
<<
>>
Prefs
   1/*
   2 *  linux/fs/block_dev.c
   3 *
   4 *  Copyright (C) 1991, 1992  Linus Torvalds
   5 *  Copyright (C) 2001  Andrea Arcangeli <andrea@suse.de> SuSE
   6 */
   7
   8#include <linux/init.h>
   9#include <linux/mm.h>
  10#include <linux/fcntl.h>
  11#include <linux/slab.h>
  12#include <linux/kmod.h>
  13#include <linux/major.h>
  14#include <linux/device_cgroup.h>
  15#include <linux/highmem.h>
  16#include <linux/blkdev.h>
  17#include <linux/module.h>
  18#include <linux/blkpg.h>
  19#include <linux/magic.h>
  20#include <linux/buffer_head.h>
  21#include <linux/swap.h>
  22#include <linux/pagevec.h>
  23#include <linux/writeback.h>
  24#include <linux/mpage.h>
  25#include <linux/mount.h>
  26#include <linux/uio.h>
  27#include <linux/namei.h>
  28#include <linux/log2.h>
  29#include <linux/cleancache.h>
  30#include <asm/uaccess.h>
  31#include "internal.h"
  32
  33struct bdev_inode {
  34        struct block_device bdev;
  35        struct inode vfs_inode;
  36};
  37
  38static const struct address_space_operations def_blk_aops;
  39
  40static inline struct bdev_inode *BDEV_I(struct inode *inode)
  41{
  42        return container_of(inode, struct bdev_inode, vfs_inode);
  43}
  44
  45inline struct block_device *I_BDEV(struct inode *inode)
  46{
  47        return &BDEV_I(inode)->bdev;
  48}
  49EXPORT_SYMBOL(I_BDEV);
  50
  51/*
  52 * Move the inode from its current bdi to a new bdi. If the inode is dirty we
  53 * need to move it onto the dirty list of @dst so that the inode is always on
  54 * the right list.
  55 */
  56static void bdev_inode_switch_bdi(struct inode *inode,
  57                        struct backing_dev_info *dst)
  58{
  59        struct backing_dev_info *old = inode->i_data.backing_dev_info;
  60
  61        if (unlikely(dst == old))               /* deadlock avoidance */
  62                return;
  63        bdi_lock_two(&old->wb, &dst->wb);
  64        spin_lock(&inode->i_lock);
  65        inode->i_data.backing_dev_info = dst;
  66        if (inode->i_state & I_DIRTY)
  67                list_move(&inode->i_wb_list, &dst->wb.b_dirty);
  68        spin_unlock(&inode->i_lock);
  69        spin_unlock(&old->wb.list_lock);
  70        spin_unlock(&dst->wb.list_lock);
  71}
  72
  73/* Kill _all_ buffers and pagecache , dirty or not.. */
  74void kill_bdev(struct block_device *bdev)
  75{
  76        struct address_space *mapping = bdev->bd_inode->i_mapping;
  77
  78        if (mapping->nrpages == 0)
  79                return;
  80
  81        invalidate_bh_lrus();
  82        truncate_inode_pages(mapping, 0);
  83}       
  84EXPORT_SYMBOL(kill_bdev);
  85
  86/* Invalidate clean unused buffers and pagecache. */
  87void invalidate_bdev(struct block_device *bdev)
  88{
  89        struct address_space *mapping = bdev->bd_inode->i_mapping;
  90
  91        if (mapping->nrpages == 0)
  92                return;
  93
  94        invalidate_bh_lrus();
  95        lru_add_drain_all();    /* make sure all lru add caches are flushed */
  96        invalidate_mapping_pages(mapping, 0, -1);
  97        /* 99% of the time, we don't need to flush the cleancache on the bdev.
  98         * But, for the strange corners, lets be cautious
  99         */
 100        cleancache_invalidate_inode(mapping);
 101}
 102EXPORT_SYMBOL(invalidate_bdev);
 103
 104int set_blocksize(struct block_device *bdev, int size)
 105{
 106        /* Size must be a power of two, and between 512 and PAGE_SIZE */
 107        if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
 108                return -EINVAL;
 109
 110        /* Size cannot be smaller than the size supported by the device */
 111        if (size < bdev_logical_block_size(bdev))
 112                return -EINVAL;
 113
 114        /* Don't change the size if it is same as current */
 115        if (bdev->bd_block_size != size) {
 116                sync_blockdev(bdev);
 117                bdev->bd_block_size = size;
 118                bdev->bd_inode->i_blkbits = blksize_bits(size);
 119                kill_bdev(bdev);
 120        }
 121        return 0;
 122}
 123
 124EXPORT_SYMBOL(set_blocksize);
 125
 126int sb_set_blocksize(struct super_block *sb, int size)
 127{
 128        if (set_blocksize(sb->s_bdev, size))
 129                return 0;
 130        /* If we get here, we know size is power of two
 131         * and it's value is between 512 and PAGE_SIZE */
 132        sb->s_blocksize = size;
 133        sb->s_blocksize_bits = blksize_bits(size);
 134        return sb->s_blocksize;
 135}
 136
 137EXPORT_SYMBOL(sb_set_blocksize);
 138
 139int sb_min_blocksize(struct super_block *sb, int size)
 140{
 141        int minsize = bdev_logical_block_size(sb->s_bdev);
 142        if (size < minsize)
 143                size = minsize;
 144        return sb_set_blocksize(sb, size);
 145}
 146
 147EXPORT_SYMBOL(sb_min_blocksize);
 148
 149static int
 150blkdev_get_block(struct inode *inode, sector_t iblock,
 151                struct buffer_head *bh, int create)
 152{
 153        bh->b_bdev = I_BDEV(inode);
 154        bh->b_blocknr = iblock;
 155        set_buffer_mapped(bh);
 156        return 0;
 157}
 158
 159static ssize_t
 160blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
 161                        loff_t offset, unsigned long nr_segs)
 162{
 163        struct file *file = iocb->ki_filp;
 164        struct inode *inode = file->f_mapping->host;
 165
 166        return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
 167                                    nr_segs, blkdev_get_block, NULL, NULL, 0);
 168}
 169
 170int __sync_blockdev(struct block_device *bdev, int wait)
 171{
 172        if (!bdev)
 173                return 0;
 174        if (!wait)
 175                return filemap_flush(bdev->bd_inode->i_mapping);
 176        return filemap_write_and_wait(bdev->bd_inode->i_mapping);
 177}
 178
 179/*
 180 * Write out and wait upon all the dirty data associated with a block
 181 * device via its mapping.  Does not take the superblock lock.
 182 */
 183int sync_blockdev(struct block_device *bdev)
 184{
 185        return __sync_blockdev(bdev, 1);
 186}
 187EXPORT_SYMBOL(sync_blockdev);
 188
 189/*
 190 * Write out and wait upon all dirty data associated with this
 191 * device.   Filesystem data as well as the underlying block
 192 * device.  Takes the superblock lock.
 193 */
 194int fsync_bdev(struct block_device *bdev)
 195{
 196        struct super_block *sb = get_super(bdev);
 197        if (sb) {
 198                int res = sync_filesystem(sb);
 199                drop_super(sb);
 200                return res;
 201        }
 202        return sync_blockdev(bdev);
 203}
 204EXPORT_SYMBOL(fsync_bdev);
 205
 206/**
 207 * freeze_bdev  --  lock a filesystem and force it into a consistent state
 208 * @bdev:       blockdevice to lock
 209 *
 210 * If a superblock is found on this device, we take the s_umount semaphore
 211 * on it to make sure nobody unmounts until the snapshot creation is done.
 212 * The reference counter (bd_fsfreeze_count) guarantees that only the last
 213 * unfreeze process can unfreeze the frozen filesystem actually when multiple
 214 * freeze requests arrive simultaneously. It counts up in freeze_bdev() and
 215 * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze
 216 * actually.
 217 */
 218struct super_block *freeze_bdev(struct block_device *bdev)
 219{
 220        struct super_block *sb;
 221        int error = 0;
 222
 223        mutex_lock(&bdev->bd_fsfreeze_mutex);
 224        if (++bdev->bd_fsfreeze_count > 1) {
 225                /*
 226                 * We don't even need to grab a reference - the first call
 227                 * to freeze_bdev grab an active reference and only the last
 228                 * thaw_bdev drops it.
 229                 */
 230                sb = get_super(bdev);
 231                drop_super(sb);
 232                mutex_unlock(&bdev->bd_fsfreeze_mutex);
 233                return sb;
 234        }
 235
 236        sb = get_active_super(bdev);
 237        if (!sb)
 238                goto out;
 239        error = freeze_super(sb);
 240        if (error) {
 241                deactivate_super(sb);
 242                bdev->bd_fsfreeze_count--;
 243                mutex_unlock(&bdev->bd_fsfreeze_mutex);
 244                return ERR_PTR(error);
 245        }
 246        deactivate_super(sb);
 247 out:
 248        sync_blockdev(bdev);
 249        mutex_unlock(&bdev->bd_fsfreeze_mutex);
 250        return sb;      /* thaw_bdev releases s->s_umount */
 251}
 252EXPORT_SYMBOL(freeze_bdev);
 253
 254/**
 255 * thaw_bdev  -- unlock filesystem
 256 * @bdev:       blockdevice to unlock
 257 * @sb:         associated superblock
 258 *
 259 * Unlocks the filesystem and marks it writeable again after freeze_bdev().
 260 */
 261int thaw_bdev(struct block_device *bdev, struct super_block *sb)
 262{
 263        int error = -EINVAL;
 264
 265        mutex_lock(&bdev->bd_fsfreeze_mutex);
 266        if (!bdev->bd_fsfreeze_count)
 267                goto out;
 268
 269        error = 0;
 270        if (--bdev->bd_fsfreeze_count > 0)
 271                goto out;
 272
 273        if (!sb)
 274                goto out;
 275
 276        error = thaw_super(sb);
 277        if (error) {
 278                bdev->bd_fsfreeze_count++;
 279                mutex_unlock(&bdev->bd_fsfreeze_mutex);
 280                return error;
 281        }
 282out:
 283        mutex_unlock(&bdev->bd_fsfreeze_mutex);
 284        return 0;
 285}
 286EXPORT_SYMBOL(thaw_bdev);
 287
 288static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
 289{
 290        return block_write_full_page(page, blkdev_get_block, wbc);
 291}
 292
 293static int blkdev_readpage(struct file * file, struct page * page)
 294{
 295        return block_read_full_page(page, blkdev_get_block);
 296}
 297
 298static int blkdev_write_begin(struct file *file, struct address_space *mapping,
 299                        loff_t pos, unsigned len, unsigned flags,
 300                        struct page **pagep, void **fsdata)
 301{
 302        return block_write_begin(mapping, pos, len, flags, pagep,
 303                                 blkdev_get_block);
 304}
 305
 306static int blkdev_write_end(struct file *file, struct address_space *mapping,
 307                        loff_t pos, unsigned len, unsigned copied,
 308                        struct page *page, void *fsdata)
 309{
 310        int ret;
 311        ret = block_write_end(file, mapping, pos, len, copied, page, fsdata);
 312
 313        unlock_page(page);
 314        page_cache_release(page);
 315
 316        return ret;
 317}
 318
 319/*
 320 * private llseek:
 321 * for a block special file file->f_path.dentry->d_inode->i_size is zero
 322 * so we compute the size by hand (just as in block_read/write above)
 323 */
 324static loff_t block_llseek(struct file *file, loff_t offset, int origin)
 325{
 326        struct inode *bd_inode = file->f_mapping->host;
 327        loff_t size;
 328        loff_t retval;
 329
 330        mutex_lock(&bd_inode->i_mutex);
 331        size = i_size_read(bd_inode);
 332
 333        retval = -EINVAL;
 334        switch (origin) {
 335                case SEEK_END:
 336                        offset += size;
 337                        break;
 338                case SEEK_CUR:
 339                        offset += file->f_pos;
 340                case SEEK_SET:
 341                        break;
 342                default:
 343                        goto out;
 344        }
 345        if (offset >= 0 && offset <= size) {
 346                if (offset != file->f_pos) {
 347                        file->f_pos = offset;
 348                }
 349                retval = offset;
 350        }
 351out:
 352        mutex_unlock(&bd_inode->i_mutex);
 353        return retval;
 354}
 355        
 356int blkdev_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 357{
 358        struct inode *bd_inode = filp->f_mapping->host;
 359        struct block_device *bdev = I_BDEV(bd_inode);
 360        int error;
 361        
 362        error = filemap_write_and_wait_range(filp->f_mapping, start, end);
 363        if (error)
 364                return error;
 365
 366        /*
 367         * There is no need to serialise calls to blkdev_issue_flush with
 368         * i_mutex and doing so causes performance issues with concurrent
 369         * O_SYNC writers to a block device.
 370         */
 371        error = blkdev_issue_flush(bdev, GFP_KERNEL, NULL);
 372        if (error == -EOPNOTSUPP)
 373                error = 0;
 374
 375        return error;
 376}
 377EXPORT_SYMBOL(blkdev_fsync);
 378
 379/*
 380 * pseudo-fs
 381 */
 382
 383static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock);
 384static struct kmem_cache * bdev_cachep __read_mostly;
 385
 386static struct inode *bdev_alloc_inode(struct super_block *sb)
 387{
 388        struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
 389        if (!ei)
 390                return NULL;
 391        return &ei->vfs_inode;
 392}
 393
 394static void bdev_i_callback(struct rcu_head *head)
 395{
 396        struct inode *inode = container_of(head, struct inode, i_rcu);
 397        struct bdev_inode *bdi = BDEV_I(inode);
 398
 399        kmem_cache_free(bdev_cachep, bdi);
 400}
 401
 402static void bdev_destroy_inode(struct inode *inode)
 403{
 404        call_rcu(&inode->i_rcu, bdev_i_callback);
 405}
 406
 407static void init_once(void *foo)
 408{
 409        struct bdev_inode *ei = (struct bdev_inode *) foo;
 410        struct block_device *bdev = &ei->bdev;
 411
 412        memset(bdev, 0, sizeof(*bdev));
 413        mutex_init(&bdev->bd_mutex);
 414        INIT_LIST_HEAD(&bdev->bd_inodes);
 415        INIT_LIST_HEAD(&bdev->bd_list);
 416#ifdef CONFIG_SYSFS
 417        INIT_LIST_HEAD(&bdev->bd_holder_disks);
 418#endif
 419        inode_init_once(&ei->vfs_inode);
 420        /* Initialize mutex for freeze. */
 421        mutex_init(&bdev->bd_fsfreeze_mutex);
 422}
 423
 424static inline void __bd_forget(struct inode *inode)
 425{
 426        list_del_init(&inode->i_devices);
 427        inode->i_bdev = NULL;
 428        inode->i_mapping = &inode->i_data;
 429}
 430
 431static void bdev_evict_inode(struct inode *inode)
 432{
 433        struct block_device *bdev = &BDEV_I(inode)->bdev;
 434        struct list_head *p;
 435        truncate_inode_pages(&inode->i_data, 0);
 436        invalidate_inode_buffers(inode); /* is it needed here? */
 437        clear_inode(inode);
 438        spin_lock(&bdev_lock);
 439        while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) {
 440                __bd_forget(list_entry(p, struct inode, i_devices));
 441        }
 442        list_del_init(&bdev->bd_list);
 443        spin_unlock(&bdev_lock);
 444}
 445
 446static const struct super_operations bdev_sops = {
 447        .statfs = simple_statfs,
 448        .alloc_inode = bdev_alloc_inode,
 449        .destroy_inode = bdev_destroy_inode,
 450        .drop_inode = generic_delete_inode,
 451        .evict_inode = bdev_evict_inode,
 452};
 453
 454static struct dentry *bd_mount(struct file_system_type *fs_type,
 455        int flags, const char *dev_name, void *data)
 456{
 457        return mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC);
 458}
 459
 460static struct file_system_type bd_type = {
 461        .name           = "bdev",
 462        .mount          = bd_mount,
 463        .kill_sb        = kill_anon_super,
 464};
 465
 466static struct super_block *blockdev_superblock __read_mostly;
 467
 468void __init bdev_cache_init(void)
 469{
 470        int err;
 471        static struct vfsmount *bd_mnt;
 472
 473        bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
 474                        0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
 475                                SLAB_MEM_SPREAD|SLAB_PANIC),
 476                        init_once);
 477        err = register_filesystem(&bd_type);
 478        if (err)
 479                panic("Cannot register bdev pseudo-fs");
 480        bd_mnt = kern_mount(&bd_type);
 481        if (IS_ERR(bd_mnt))
 482                panic("Cannot create bdev pseudo-fs");
 483        blockdev_superblock = bd_mnt->mnt_sb;   /* For writeback */
 484}
 485
 486/*
 487 * Most likely _very_ bad one - but then it's hardly critical for small
 488 * /dev and can be fixed when somebody will need really large one.
in4ss="line" name="L389"> 34389">4869* Keeps inmiandthats it will be eed hrough i_cachs hsh funcatio tooe.
4980 */
4931static inline unsignedlongc ( 4932{
4953        return ((4984}
4985
4966static>int bdevneist(struct inode *inode, void *data)
4987{
4983        return BDEV_I(inode)->bdevb_bdev = *>(*)*datain4399" class="line" name="4399">4929}
5030
5016static>int (struct inode *inode, void *data)
5032{
5083        BDEV_I(inode)->bdevb_bdev  *>(*)*data5404        return 0;
5405}
5406
5407static**bdepv5098
5409block_device *( 5410{
5171        struct block_device *bdev5412       (struct inode *inode5153
5414        inode = rge5v_loceaR(blockdev_superblock, (5175                        bdevneist, , &5106
5417        if (!inode)
5148                return NULL;
5159
5280        bdev = &BDEV_I(inode)->bdev;
5211
5272        if (inode->i>stad2;& _NEWe= {
5273                bdev->bd>contaiee = NULL;
5274                bdev-> = NULL;
5275                bdev->bd_inode = inode5276                bdev-> =(1> < <  inode->i_lkbitev5247                bdev->bdpartd>coune = 0;
5248                bdev-> = 0;
5279                inode->i_node = 5340                inode-> = 5310                inode->i_bdev = bdev;
5382                inode->i_data = &;
5373                mappinvmse_gfp_mascI(&inode->i_data,;GFPUSERv5374                inode->i_data = &;
5375                spin_lock(&bdev_lock);
5376                listadak(&bdev->bd_list, &bdepv5347                spin_unlock(&bdev_lock);
5348                (inode);
5439       >}
5440        return bdev;
5441}
5472
5443EXPORT_SYMBOL();
5474
5445//*
5486
5487 *@;bdev       Bblock device tograb a  rfereance te.
5488 */
5409block_device * struct block_device *bdev)
5510{
5521        _holL(bdev->bd_inode);
5520        return bdev;
5453}
5574
5455(void)
5456{
5597        struct block_device *bdev5548       longc  = 0;
5519        spin_lock(&bdev_lock);
5680        listfor_eacht_entrL(bdev, &bdepv, bd_list= {
5610                + = bdev->bd_inode->i_mapping->5462       >}
5643        spin_unlock(&bdev_lock);
5604        return 5605}
5606
5467bpusL struct block_device *bdev)
5608{
5619        (bdev->bd_inode);
5700}
5711
5472EXPORT_SYMBOL(bpusL);
5473;
5754static struct block_device *bdacquirdL struct inode *inode)
5725{
5476        struct block_device *bdev5767
5738        spin_lock(&bdev_lock);
5719        bdev = inode->i_bdev5480        if (bdev= {
5810                _holL(bdev->bd_inode);
5482                spin_unlock(&bdev_lock);
5873                return bdev;
5804       >}
5835        spin_unlock(&bdev_lock);
5806
5877        bdev = (inode->);
5878        if (bdev= {
 35389">5879                spin_lock(&bdev_lock);
5940                if (!inode->i_bdev= {
5910                        /*
5932>>>>>>>>>>>>>>>>>>>>>>>>* We takeo n addiatioal  rfereance to>bd_inod,*
5953>>>>>>>>>>>>>>>>>>>>>>>>*  and it'sreleaseds in>clear_inod() of _inode.
5984>>>>>>>>>>>>>>>>>>>>>>>>* So, wed canaccesis itvia >->>i_mappin always.
5945>>>>>>>>>>>>>>>>>>>>>>>>* without irrab()e.
5986>>>>>>>>>>>>>>>>>>>>>>>**/
5947                        _holL(bdev->bd_inode);
5948                        inode->i_bdev = bdev;
in5399" class="line" name="5399">5979                        inode->i_mapping = bdev->bd_inode->i_mapping;
6040                        listadak(&inode->i_devices, &bdev->bd_inodes);
6010               >}
6082                spin_unlock(&bdev_lock);
6083       >}
6404        return bdev;
6405}
6406
6407static*inline>int  struct super_block *)
6008{
6094        return  =  blockdev_superblock;
6100}
6111
6132**/
6153
6414 struct inode *inode)
6125{
6176        struct block_device *bdev = NULL;
6167
6138        spin_lock(&bdev_lock);
6194        if (inode->i_bdev= {
6240                if (!(inode->))
6210                        bdev = inode->i_bdev6282                __bd_forget(inode);
6283       >}
6274        spin_unlock(&bdev_lock);
6285
6276        if (bdev>
6247                (bdev->bd_inode);
6258}
6259
6380//*
6310
6332 *@;bdev  block devicdof _itereist
6353 *@whole: wholea block devicd contaipin @;bde, may equal @;bdet
6384 *@_holer: _holer trypin toe clim @;bdet
6345/*
6386
6387 .
6388 *CONTEXT:.
6369* >spin_loc>(&>bdev_loc)e.
6480 .
6410
6432 *%stre  if@;bded can be climta,*%falscdotherwisde.
6453 */
6454static;ool7;bdmay_ climt struct block_device *bdevblock_device *
6475                         void *>
6456{
6417        if (bdev-> =  >
6448                return 
6494       elscd if (bdev->! = NULL>
6540                return 
6521       elscd if (bdev->bd>contaiee  = bdev>
6582                return 
6553
6541       elscd if (-> =  bdmay_ climt>
6575                return 
6561       elscd if (->! = NULL>
6547                return 
6548       elsc>
6579                return 
6600}
6611
6632
6653 *>bdprepare_to_ clim - prepare toe clim aa block devic*
6684 *@;bdev  block devicdof _itereist
6645/*@whole: the wholea devicd contaipin @;bde, may equal @;bdet
6686
6687 .
6688 *Prepare toe clim @;bde.  This funcatio fails  if@;bdedis al_reay.
6669*  climta by*another _holer  andwaits  ifanother  climpin is in.
6780  progreis.  This funcatio doesnt't actueally clim.  On succesifull
6710bd>climpin  and=bd_holer[s]e.
6732 .
6753 *CONTEXT:.
6784 *>spin_loc>(&>bdev_loc)e  Mightsrelease >bdev_loc, sleeps andrerrabL
6745/*it multipleatimtse.
6786
6787 *RETURNS:.
6788 *0  if@;bded can be climta,*-EBUSYdotherwisde.
6769**/
6480static>int  struct block_device *bdev
6810                               struct block_device *>
6832{
68436804        **/
6835        if (!bdmay_ climt*bdev>>
6876                return-*6867
6878        **/
 36389">6894        if (->bd>climpinv= {
6940               ( * = it_waitqueuek(&->bd>climpinv);
6910               ;*);
6972
6973                *, &);
6974                spin_unlock(&bdev_lock);
6975                >);
6976                *, &);
6947                spin_lock(&bdev_lock);
6948               gotoe 6939       >}
70407010        
7020        return 0;
7053}
7074
7045//*
7086strtd>climpin - >strt* climpin aa block devic*
7087 *@;bdev  block devicdof _itereist
7088 *@_holer: _holer trypin toe clim @;bdet
7069*t
7180  @;bdedis about  to>cdopeoea exclusively.  Cheock@;bded can beopeoeat
7110
7132 *>uccesiful ceal  tothis funcatio mustn bematched with aaceal  tt
7153 *either _bd_aipsh_ climpin() or _bdabortd>climpin() (which do nost
7184 *fail)e.
7145/*
7186
7187 *without actueally ausiin other exclusiveeopeo attemptis tofail. Ist
7188 *shoula be useds whentheaopeo sequeanceitself  rquirds exclusivet
7169* accesisbut may subsequeatllyfail.t
7280 .
7210
7232 *Mightssleep.t
7253 t
7284 *RETURNS:.
7245/*Po_iters tothea block devicd contaipin @;bde on succesi, ERR_PTR().
7286
7287 */
7258static struct block_device *bd>strtd>climpint struct block_device *bdev
7279                                              void *>
7310{
7310        struct  *7382        struct block_device *7373       >int 7374
7375       *>);
7306
7347        /*
7388>>>>>>>>  @;bdedmight nos haveebeeo initializedsproperllyyet, look up*
7369>>>>>>>>   andgrab theaouters block devicdtheaharndwaye.
7480>>>>>>>> */
7421         = *bdev->b_bdev);
7482        if (!>
7473                return -*);
7474
7475        /*
7486>>>>>>>  Normeall, @;bdedshoula equal whait'sreeturedsfrom =brge_disc().
7487>>>>>>>>   ifpartnd is 0; however,* som drivers (floppy) use multiple.
7488>>>>>>>>  ;bdet'sfor*theasnam physical  devicd and@;bdedmayn beoncdof the.
7469>>>>>>>>   liases.  Keeps@;bdediifpartnd is 0.  This meanse climerv
7580>>>>>>>>  trackpin is brokeo for*thosea devicisbut it _as alwaysebeeo  hatv
7510>>>>>>>  waye.
7532>>>>>>>> */
7532        if ;>
7574                 = *);
7575       elsc>
7576                 = *bdev);
7567
7538        *->->);
7519        *);
7680        if (!>
7610                return -*);
7672
7643         */
7674        spin_lock(&bdev_lock);
7685
7664         = *bdev);
7617        if ( = 0>= {
7648               *->bd>climpinv = 7679                spin_unlock(&bdev_lock);
7740                return 7710       }eelscd {
7782                spin_unlock(&bdev_lock);
7773                bpusL);
7774                return ();
7775       >}
7786}
7767
7788
7769 {
7480        struct listhrea4        lisv7810        struct >>>>>>>>> *7482       >inttttttttttttttttttttt*78437874
7835static struct  * struct block_device *bdev
7876                                                  struct  *>
78677878        struct  * 37389">7859
7940        listfor_each_enetrt(, &bdev->bd_holer_discevlisv>
7910                if (->  = >
7982                        return 7973        return NULL;
7974}
7985
7976static>int  struct  * *>
79677948        return ((>);
7939}
80408010static void  struct  * *>
8032{
8083        ((>);
8074}
8085
8086//*
8087 *>bd"lic_discd_holer - create sym"licsebetweeo _holpin discd andslaveebddet
8088 *@;bdev the cclimta slaveebddet
8069* @discv the _holpin disct
8180 t
8110
8132 .
8153 *This funcatios creates the followpin _ysfs sym"licse.
8184 .
8145/ - from "slaves" direcsorydof the _holer @discs totheacclimta @;bdet
8186
8187 t
8188 *For example, if*/_de/dm-0 mapis to/_de/sdad anddiscsfor*dm-0 ist
8169* plaseds to>bd"lic_discd_holer(), then:.
8280 .
8210-> /_yss/bloc/sda.
8232 *  /_yss/bloc/sda/_holers/dm-0 ->-> /_yss/bloc/dm-0.
8253 t
8284 *The cealer mustnhaveecclimta @;bdeebefore cealpin this funcatio  ant
8245/*ensurce hatsboth @;bdee and@discd rcevaloiddurpin the creattio  ant
8286
8287 .
8288 *CONTEXT:.
8269* Mightssleep.t
8380 .
8310
8332 *0 on succesi, -errno io failurde.
8353 */
8374int bd"lic_discd_holert struct block_device *bdev *>
8375{
8376        struct  *8347       >int =n 0;
83888319        (&bdev->);
84408421        (!bdev->);
8472
8443         */
8474        if ((!->|| (!bdev->->>>
8475               gotoe 8406
8417       * = *bdev);
8448        if (= {
8479                ->8540               gotoe 8521       >}
8572
8583         =  izeof( *);
8574        if (!= {
8575                =n-*8576               gotoe 8547       >}
85888519        (&->lisv);
8640        ->  *8621        ->  1);
8672
8683        =n !->*bdev->->);
8674        if (>
8675               gotoe 8606
8617       *=n !bdev->->!->);
8648        if (>
8679               gotoe 8740        /*
8710
8732          thea_holer direcsory.  Hhol io toeite.
8753         */
8774       ;!bdev->->);
8785
8764        listaddk(&->lisv, &bdev->bd_holer_discev);
8717       gotoe 878887698840        !->*bdev->->);
88108482       ;);
88438874       ;(&bdev->);
8835        return 8886}
8867*bd"lic_discd_holert);
8888 38389">8869//*
8980  >bd_unlic_discd_holer - destroy sym"licsecreatea byo>bd"lic_discd_holer()*
8910
8932 *@discv the _holpin disct
8953 t
8984 *DONt'T USE THIS UNLESS YOUt'RE ALREADY USING ITe.
8945/*
8986
8987 *Mightssleep.t
8988 */
8939bd_unlic_discd_holert struct block_device *bdev *>
9010{
9010        struct  *9072
9083        (&bdev->);
9074
9075       * = *bdev);
9006
9017        if (!*  = NULL->= {
9048               *!->*bdev->->);
9079                !bdev->->
9140                           (&!->);
9110               ;!bdev->->);
9182                listdel_initk(&->lisv);
9173                );
9174       >}
9185
9164        (&bdev->);
9187}
9188*bd_unlic_discd_holert);
916992409210//*
9232 *flush_disc - invaloiates all buffer-cache eneties io   disct
9253 t
9284 *@;bdev       struct/block devicdto be flushent
9245/*@kill_dirty: flagdto guidenhandlpin of dirty incodst
9286
9287  Invaloiates all buffer-cache eneties io   disc. Itdshoula be cealent
9288 *wheo   disc _as beeo changed -- eithers y   media change or io"lint
9269* re ize.t
9380 */
9310static void  struct block_device *bdev >
9332{
9332        if ;*bdev>= {
9374               char * = ""/9385
9376                if ;bdev->>
9347       >                !bdev->);
9348               *! "VFS: busy incods io changed media or "/9379                      *"re izenddiscs%s\n"/);
9440       >}
94219422        if (!bdev->>
9473                retur);
9474        if (!bdev->>>
9475               !bdev-> =1);
9486}
9467
9488//*
9469* checc_discd ize_change - checcssfor*discs ize change  andadjusts ;bde  ize.t
9580  @discv  structgendisc toe hecct
9510
9532 .
9553 *This routlin checcss tosee  ifthe ;bde  ize dods not matchfthe discs ize.
9584 * andadjusts it  ifit differse.
9545/*/
9576 struct  *block_device *bdev>
95679548       ;off_se 9559
9640         =>!off_se!9621         = !bdev->);
9622        if  ! = = {
9673               char *9674
9675                !);
9676               *!
9647       >               "%s: detectea capacity change from %llds to%lld\n"/
9648                      *);
9679                !bdev->);
9740                *bdev);
9721       >}
9732}
9743*);
9774
9745//*
9786
9787  @discv  structgendisc toebe revaloiatent
9788 t
9769* This routlin is a wrappersfor*lower-level drivert's revaloiatek_isct
9880  ceal-baccs.  Itdis useds todo "comon pre  andpost operaatios needent
9810
9832 */
9843int  struct  *>
98749835        struct block_device *bdev9876       >int =n 0;
9867
9848        if (->->>
 39389">9879                =n ->->!99409921        bdev = !9922        if (!bdev>
9973                return 9974
9975       *(&bdev->);
9964        !bdev);
9917       *(&bdev->);
9948       ;*bdev);
9979        return 
*);
/*
 *This routlin checcsswhethersa removable media _as beeo changed,*
/* andinvaloiates all buffer-cache-eneties ine hatscase.*This*

  it.*Thus it  s cealen io"y upio   t'mountt' or &'open&'.*This*
 * s the ;est waydof "cobining speen  andutllity, I thinke.
* People changpin discettes ine he middltdof panoperaatio deserve.
*  tolose :-)*

 struct block_device *bdev>
 * = bdev->block_devic_operaatiose *=n ->=n !|>
);
(& !>>
*bdev);
->>
->!bdev->);
*);
bdsetd izee" class="sref"=_dsetd izet struct block_device *bdevoff_se ;
 = *bdev);
bdev->-> = < (= {
(& !;
<< =1);
bdev-> = bdev->-> = *);
*);
 struct block_device *bdev int );
//
* =bdmutex blocing:.
*.
->=bdmutex)*
 *   mutexv_loc_nested(whole>->=bdmutex, 1)*
 */
 struct block_device *bdev int >
 * * = 0;
(& !>
| = (& !>
| = //
>>>>>>>>* hooks: /n/,osee "layetpin violaatios"e.
>>>>>>>>**/
= {
=n !bdev->);
! = >= {
lass="sreff="+codechecc_discd ize_eff="ef="ODE_READe" class="sreeeeeeeeebdev" class="sref">bdev);
ef="8ref">block_device
cl r="+code= izee" class="sref"= {
104eal-baccs.  Itdis useds 04eal>cl s="line" name="10440>10449{
=n  "lict!cl ef="+codedisck" class="sref"disceisce" class="sref"revaloiatek_isct struct 10482d="9482" class="line" na82d=">cl +coderesk" class="sregotoa>        structo="fs/block_dev.c#oublock_dev.c#9319" id="9399" class=8lass="srefsck" class="sref"gendiscefsck>cl 4="line" name="10440>10449 39389">9879                =lass="line" name="10458>10487        struct block_devic"mcla>cl code=bdmutexk" class="sref"=href=ef"=_d"line" name="10418>10448->9876       s=e=">cl  href="+code=bdev" class="sref">bd
bd
9917       * struct  9421cl 10448                       breaks" class="sref"=bope5-> 39389mcod_se clss0448                       breaks" class="sref"=bope5-> 39389">9879          queef="+codeflush_diqueef0487mcod_se 104
ks" class="sref"=bope5->-mcod_se clsef="+codepermk" class="srine" name="9441"codea);
10482me="9392">9922      82me=>cls+coderesk" class="sref"hrs5-mcod_se 9973              ef">9>cls453 */<9ermk" clas
= {
bdev->clsE_WRITEk" class="srefass="sref"fordpars5ks" class="sref"=bope5->-rmisstiot!cls="+code=bdbisck" class="sref"s="line" name="9441">9421bdev->        structo="/a>   fs/block_dev.c#oub/a>   lock_dev.c#9319" id="9399" class=9class="comdpust" class="sref"bdpusomdpu>clsode=_ded izee" class="sref"=_de11"line" nam1="9399">9979        r1turn 10e_holer_dire" class="sref"_hof"fordpars5= {
 39389">9879                =llinfs/block_dev.c#olinev.c " id="10470" class="line" nam1PORT_SYMBO1t*= {
 39389">9879                =llinfs/block_dev.c#olinev.c30" id="10423" class="line" name="10423>10483        );
*);
9973              e11049310ODE_READe" class="sreeeeeeeee class="sref"_hofass="sref"MAY_WRITE51*This routlin checcsswhet1ersa 1emovable media _as beeo changgggggggggggggggggggggggggggggggggggggggg* dele="f,="104agaicss="line" name="10468>10488/* andinvaloiates all 1uffer1cache-eneties ine hatscase.*Tgggggggggggggggggggggggggggggggggggggggg* See md.cs="line" name="10468>10488
=n |>
=====c#10480" id="10ks" class="sref"=bope5->1 People changpin discette1 ine 11e_holer_dire" class="sref"_hoNGEe|>
=====c#10480" id="10ks" class="sref"=bope5->}
/pre>1="line" name="10410>104191/a>|>
=====c#10480" id="10ks" class="sref"=bope5->
=====c#10480" id="10ef">bdev);
9917       *(&block_device *
=====c#10480" id="10418" unef"=_d"line" name="10418>10448->!->1ss="sref">bdev->
=====c#10480" id="10e_dev.
-1gt;        structref=>
       unsigned >int 1a hre11="+code=bdbisck" class="sref"""""""""de= izee" class="sref"= ize.1e9421104389640         =>!of490" id=9>laiclass="sref"=bopei/a>->);
-&gev.c#9419" id="9sNUL37}
bdev!-> id="9397" class="lidefaul93maa hrelinepdif);
->!=n !->bdev->}
** =bdmutex blocit;e.off_se<1a> ->=bdmutt;e.*);
        structrefcet_="sritodesa href="fs/blocrefcet_="sritodesresk" class="sref"hrpes" class="sref"fopee-rmisstiot!1lt; (*(&1!        structdi_dev.c#9_="sritodesa href="fs/blocdi_dev.c#9_="sritodesresk" class="sref"hrpes" class="sref"fopee-rmisstiot!}
10448                    de= izee" class="sref"= ize.1>104791                       structo="/a>   fs/block_dev.c#oub/a>   lock_dev.c#9319" id="9399" class1zee" class1"sref"=__/block izet 1 1static>i/bloclock_dev.c#9319" id="9399" class1zss="sref"1ef="fs/block_dev.c#10430"1id="114ODE_READe" class="sreeeeeeeeekblk_dedgesk" c/bloc454static>i/bloclockblock_dev.c#9371" id="9391" class="line" name="9391">9921        bdev = bd14isce" class="sref"revass="sref"fordpars5= {
static>i/bloclocka             9453"= hrefent1  ize.1sref"mood4int         structo="/a>   fs/block_dev.c#oub/a>   lock_dev.c#9319" id="9399" class1zn1);
                             f"fordpars5= {
static>i/bloclock83                 structo="/a>   fs/block_dev.c#oub/a>   lock_dev.c#9319" id="9399" class1name="10451>10410static>i/bloclock_dev.c#9319" id="9399" class10432 *   m1texv_15+coderesk" class="sref"hrs5! = >= {
=n 104.v.c#10420" id="1aa hrelinepdif);
);
ks" class="sref"=bope5->-rmisstiot!int  39389">9879           lag   !>
94219421 *= {
1*gotoa>        structo="/a>   fs/block_dev.c#oub/a>   lock_dev.c#9319" id="9399" class1s="line" n1me="10459>10479      1>int 16e_holer_dire" class="sref"_hode= izee" class="sref"= ize.1e" name="11460>10469       >int 1a hre16ss="sref"DISK_EVENT_MMMMMMMMMc#9422" id="9442" 0>104389640        9421(& !-0" id="10470" class="line" nam1permk" cla1s="sref"permt| = = {
(& !9879                =llinfs/block_dev.c#olinev.c 10610" id="10461" class="li1a/a>>
| = = {
9879                =llinfs/block_dev.c#olinev.c30" id="10423" class="line" name="10423>10483        
>>>>>>>>* hooks: /n1,osee16ss="sref"DISK_EVENT_MEDIA_CHAs="l.c#9419" id="9sla=n s="line" name="9441"= {
= fcet_="sritodesa href="fs/blocrefcet_="sritodesresk" class="sref"hrla=n !*10481                if ;<1 href1"+coderesk" class="sref"hrs5di_dev.c#9_="sritodesa href="fs/blocdi_dev.c#9_="sritodesresk" class="sref"hrla=n !        structo="/dev.c#_lass="line" name="1o="/dev.c#_lasslock_dev.c#9319" id="9399" class17mk" class1c - wrappersfor*lower-les1c -ef17Ek" class="sref"PAGE_}t;ef17f="+code= izee" classlass="sref"MAY_WRITE5
                       breahu9391" class="line" nahu9391" resk" class="sref"hrpes" class="sref"fopee->c18s0448                       breae_dev.
101eal-baccs.  Itdis useds 01eal>c1 s="line" name}t;c18f="+code= izee" class="sref"= ize. c18ODE_READe" class="sre        9421bdev);
9917       *(&block_devic"1cla>c1 code=bdmutexk" class="sref"=href=unef"=_d"line" name="10418>10448->9876       s1e=">c1  href="+code=EDIA_CHANGEe>>
->   fs/block_dev.c#oub/a>   lock:parte" class="sref"fordpart19"10469" c1ss="sref"revaloiatek_iscc1ss=>c19r="+code= izee" class="sref"418" pu93odekobjecs_pust" cl418" pu93odekresk" class="sref"hrs5=n 101
c19f="+code= izee" class="sref"= ize.10481me="9392">9922      81me=>c1s+coderesk" cle" class="sref"= ize.9973              e1">9>c194="line" name="10440>10449=n bdev->c1sE_WRITEk" class="srefdincod_permisst0485
 c19 href="+code=bdev" class="srla=n }
bdev->block_devicec199href="+code=bdev" class="sref">bdev);
9917       *(&9979        r2turn 20r="+code= izee" class="sref"418" unef"=_d"line" name="10418>10448->->);
);
9973              e210493204="line" name="10440>104492*This routlin checcsswhet2ersa 20td izee" class="sref"=_dsetd ize2ass="comme2t">/* andinvaloiates all 2uffer20E_WRITEk" clabdev" class="sref">bdev);
2 People changpin discette2 ine 21s="comment">* =bdmutex blocin v.c#10550" -""lin a _dev.vdref=");
}
/pre>2="line" name="10410>104192/a>@0473: nt );
block_device *->=bdmutex,  @holder: exclusive holder>);mutifi>104
);
* =bdmutex blocing:.
2ss="sref">bdev->
-2gt;
       unsigned >int 2a hre21enhavee totrye tominimize us  @holderis*<>      .  Exclusive "lins may ref= fork_devs104 @holderss="line" name="10468>10488On succnss,k_deva heren="4counp of @0473/is unchange .  On fai"ure,g:.
* =bdmutex blocin @0473/is 730ss="line" name="10468>10488->=bdmutexCONTEXTf="fs/block_dev.c#10490" id="10449"2d/a>);
->=bdmutex,  Might sleepss="line" name="10468>10488);
bdev* =bdmutex blocing:.
->bdev->
 struct block_device *}
*static>i/bloclock>);
off_se<2a> );
);
* */2);
static>i/bloclock>-f_dev.c#9319" id="9399" class2<7s="comme2lt; ((&2!}
10448                    bdev" class="sref">bdePTR_ERRa href="+code=bPTR_ERR" id="10473" class="/bloc454static>i/bloclocka              9453"= hrefent2>104792                2 2bdev =  */24/a>);
*{
 = int 
            bdev" class="sref">bd);
9917       *(&);
);
v_unlock(&(&10410 *   m2texv_25+coderesk" class="sref"hrs5! = >= {
9_maylclaimlock" class="sref"maylclaim id="ne" name="9441"lass="line" name="10423>10483        static>i/bloclock83        2css="sref"20453" class="line" name="20453>25ODE_READe" class="sreeeeeeeeelass="sref"MAY_WRITE5);

int 
 *
2*
        struct/bloc454static>i/bloclockck_dev.c#10420" id="104holderslock" class="sref"holdersg:70++gt;10419       >int 2a hre26ef="+codepermk" classMMMMMMMMc#9422" id="944ne" name="9397">9917       *! = >= {
9917       *-gt;(& !| = (& !
| = ! = >= {
-f_dev.c#9319" id="9399" class2d="10467" 2lass="line" name="10467>12417static>i/bloclockck_dev.c#10420" id="104claim068lock" class="sref"claim068" id0gt;>>>>>>>>* hooks: /n2,osee26ss="sref"DISK_EVENT_Mc#9422" id="944/ake_up_bi href="fs/block_/ake_up_bi 9387" id="9397" class="li/bloc454static>i/bloclockck_dev.c#10420" id="104claim068lock" class="sref"claim068" idf">bdev = );
);
v_unlock(&10482                if ;<2 href2"+coderesk" class="srelass="sref"MAY_WRITE5* =bdmutex blociiiiiiiiiiiiiiiii* Bdev.v"line poll068sforkwrite claimsss="requeste .  Any);
ef27       *
c28s0448            s="line" name="9441"= sa href="fs/blocreflock. id="v.c#10ss="sref"MAY_READ59917       * 39389">9879           lag   !9917       *10482d="9482" class="line" na82d=">c28+coderesk" class="sref"hrs5! = >= {
->c28ODE_READe" class="sre}t;block_devic"2cla>c28E_WRITEk" class="srefkblk_dedgesk" cef">bdev);
9917       *(&9876       s2e=">c28Ek" class="sref"PAGE_a>! = >= {
->c29r="+code= izebdev" class="sref">bdev102
c29f="+class="sref">bdeEXPORT_SYMBO37}

10482me="9392">9922      82me=>c2s+code             9453"= hrefent29lass="sre2">9973              e2">9>c29ODE_Rmment">* =bdmutex bloc/*a);
bdev->c29ache-eneties ine hatscase.*T*"@path: pathc96"ev.c_dev.vdref=" 96"olinev
c29enhavee totrye tominimize us  @/blo: 10452<* maebdev->);mutifi>104
c2904889979        r3turn 30s="comment">* =bdmutex blocin Olin ev.c_dev.dref=" describe  byc_devdref="ifilevat"@path.  @/block
0480@holderiarev);muticalv96"e.c#10550"()ss="line" name="10468>10488*9922      83 id="30c_nested(whole>->=bdmutex,  On succnss,k_deva ev" e  bt * =bdmutex blocing:.
3*This routlin checcsswhet3ersa 30movable media _as beeo chang* CONTEXTf="fs/block_dev.c#10490" id="10449"3ass="comme3t">/* andinvaloiates all 3uffer30ache-eneties ine hatscase.*T*"Might sleepss="line" name="10468>10488bdev->3 People changpin discette3 ine 31s="comment">* =bdmutex blocinn>
}
/pre>3="line" name="10410>104193/a>block_device *);
block_device *);
3ss="sref">bdev->-3gt;       unsigned >int 3a hre31 href="+code=bdev" class="srla=n =n bdelass="sref"_kblk_dedgest = bdelass="sref"_kblk_dedgest        -f_dev.c#9319" id="9399" class3!ORT_SYMBO3" id="10421" class="line"3name=322="+code= izes="l.c#9419" id="9serr="sref"_kblk_deerrt bdeERR_PTR7}
bdeerr="sref"_kblk_deerrt);
bdev */3ef"=bope5<3a>->bdev->
        bdeERR_PTR7}
}
*bdelass="sref"_kblk_dedgest);
off_se<3a> bdeEXPORT_SYMBO37}

);
);
** =bdmutex bloc/*a);
);
104
(&3!}
104793               * =bdmutex blocin Olin ev.c_dev.dref=" describe  bycdref=" numb>1 @d73.  @/blo>04804
/a>);
@holderiarev);muticalv96"e.c#10550"()ss="line" name="10468>10488 3 ->=bdmutes="line" name="10468>104883->=bdmutex,  Use"st ONLY"s="you reallycdo not have anyth068sbetteri- i.e. whinev
* =bdmutex blocin"you are7beh06d a trulycsucky interfac.10480all you are7gilinkis aev
);
*1.  _Never_v96"ee use  forkinternalvpurposes.  Ickyouev
int * =bdmutex blocin CONTEXTf="fs/block_dev.c#10490" id="10449"3chref="fs/310450" class="line" name=310450350459Might sleepss="line" name="10468>1048810410->=bdmutes="line" name="10468>10488 *   m3texv_35c_nested(whole>->=bdmutex,  RETURNSf="fs/block_dev.c#10490" id="10449"3css="sref"30453" class="line" name="30453>35ODE_Rmment">* =bdmutex blocin"Pointeri96"e. int block_device        block_device * *3*bdeass="sref"_kblk_deodedevc               9453"= hrefent3eee" class3461>10419       >int 3a hre362="+code= izes="line" name="9441"renename="9397">9917   fmcod_se bdeERR_PTR7}
(& ! */3permk" cla3s="sref"permt| = bdelass="sref"_kblk_dedgest        -f_dev.c#9319" id="9399" class3ass="sref"3ood4(& ! | = bdeERR_PTR7}
bdeerr="sref"_kblk_deerrt>>>>>>>>* hooks: /n3,osee36ss="sref"DISKbdev" class="sref">bdelass="sref"_kblk_dedgest        if ( bdeEXPORT_SYMBO37}

10483                if ;<3 href3"+codestaticKs class="sref"parsnd.c#105olin="sref"_kblk_ded.c#105olinevd="10455" class="line" na" class="sref"devcgrdincod_pein"class="line" na" class="sref"devcgrdincod_pe,e10455" class="line" nafileblock_device" clilod_pein"class="line" nalilpblock_device" clilpt ef37       *c38s="comment">* =bdmutex blocit;e.c38  mutexv_loc(part>->=bdmutt;e.
10483d="9482" class="line" na83d=">c38+coderesk" cle" class="sref"lilpblock_device" clilpt9879           _ lag   c38453 */38ermk" cla39879           _ lag    block_devic"3cla>c38E_WRITEk" class="srefkblk_dedgesk" clilpblock_device" clilpt9879           _D59876       s3e=">c38Ek" class="srs="le" class="sref"lilpblock_device" clilpt9879           _ lag   -f             9453"= hrefent38="10467" 3
9879           _D5c389k" class="srs="lle" class="sref"lilpblock_device" clilpt9879           _ lag   -f.== 3f             9453"= hrefent39"10469" c3ss="sref"revaloiatek_iscc3ss=>c39e_holer_dire" class="9879           _D5103
(&c39f="+code= izee" class="sref"a>       >}
static>inb_acquir0 id="ne" name="9441"" class="sref"devcgrdincod_pef_dev.c#9319" id="9399" class390472>10483me="9392">9922      83me=>c393k" class="srs="le" class="sref"a>       >}
}
9973              e3">9>c39ODE_READe" class="srebdev" c/a>*bdev->c3sE_WRITEk" cla9879           _Dapp068lock" class="sr _Dapp068/blo>9917       *       *c39efordparte" class="sref"fordpart39="10467" 3s="sref">bdev->bdel4
bdelass="sref"_kblk_dedgest        9879           _D5c390488<}t;9979        r4turn 40e_holev =         block_device **9922      84 id="403k" class="srs class="sref"parsnre/a>);
);
9973              e41049340ODE_READe" cl10455" class="line" na/a>{
9917       * = 4*This routlin checcsswhet4ersa 40isce" class="10455" class="line" name="10455>10454static>int /* andinvaloiates all 4uffer40ache-             9453"= hrefent4a7s="comme4tisck" class="sref"disces4n, so40 href="+code=bdev" class="srblock_v.c#_neste a href="+code=bdlock_v.c#_neste evd=" id="9397" class="line" name="9397">9917       *        bdev->9917       *    -_dev.c#9319" id="9399" class4"comment">4 People changpin discette4 ine 41e_holev = }
/pre>4="line" name="10410>104194/a>9917       *-f. id="10470" class="line" nam4"ORT_SYMBO40411" class="line" name="40411>41ef="+codepermk" class9917       *);
block_device **9917   f_dev.c#9319" id="9399" class4"4a>);
=n *9917   f_dev.c#9319" id="9399" class4"comment">4ss="sref">bdev->
-4gt;
       unsigned >int 4a hre41enhavee totrye tominimize usgggggggggggggggg*n>
99179917       *   sef="fs/block_dev.c#10690" i4"9it.*Thus4codeDISK_EVENT_MEDIA_CHAN4Ek" c41ss="sref"DISK_EVENT_MMMMMMMMMMMMMMMMMMMMMMMMM id="9397" class="lidefault_baa hre_   f_dev.c#9319" id="9399" class4a href="+c4deDISK_EVENT_EJECT_REQUES4k" cl42e_holer_dire"}t;*9917       *9917   f. id="10470" class="line" nam4!ORT_SYMBO4" id="10421" class="line"4name=42ef="+codepermk" classs="la>* 39389">9879           op   9879          a leasea>);
);
* 39389">9879           op   9879          a leasea>);
 3938983        );
bdev4a>->9917       *-f. id="10470" class="line" nam4dss="comme4s="sref">bdev-> 39389">9879           op   9879          ownera href="+code=bownerlock              9453"= hrefent4!7s="comme4.c#10260" id="10426" clas4="lin42efordparte" class="sref"fordpart4!*9917       *9917       *        structNUL37}
*9917       *        structNUL37}
       >}
9917       *off_se<4a> 9917       *);
9917       *        structNUL37}
);
* */4);
* 39389               9453"= hrefent4+codeik iz4e" class="sref"id ize.(&4!9917       *(&9917   f_dev.c#9319" id="9399" class4>104794               /a>);
ORT_SYMBO4"sref"=__/block izet 4 bdev);
/a>);
4 */4z/a>);
*        block_device *codeik iz4ref="fs/block_dev.c#104504 id="44ache- id="10470" class="line" nam4z7s="comme4sref"mood4int 9917       *(& *block_device(&10410 *   m4texv_45c_nested(whole>->=bdmutex,,,,,,,,,,,,,,,,,* R lease aholeim ev._devdref=".  The holder>fields);
* =bdmutex bloci,,,,,,,,,,,,,,,,* are7protected with ne" d.  ef"mutex4is496);
);
devin hress="line" name="10468>10488int ! = >= {
);
v_unlock(& *4*9917       *bdev = *9917       *bdev = 10469       >int 4a hre46ss="sck(&10419       >int 4a hre46ef="+codepermk" class
9917       *(& !9917       *        structNUL37}
| = 9917       *(& !9917       *        structNUL37}
| = 9387" id="9397" class="line" d);
v_unlock(&>>>>>>>>* hooks: /n4,osee46ode=_ded izee" class="sref"=_de14="10469" c4ass="line" name="10469>10469        if ( vin >04804
->=bdmutt;e.  dfreass="sref"devcgrut/adfrealock  id="v.c#109397" class="line" name="9397">9917       *9917       *(&9917       *        structfalsea>);
ef47f="+code= ize}t;c48e_holer_dire""line check068s10484d="9482" class="line" na84d=">c48c_nested(whole>->=bdmutex,,,,,,,,,* from"userlc48ODE_Rmment">* =bdmutex bloci,,,,,,,,*n>
9917       *        (&block_devic"4cla>c48ache-             9453"= hrefent487s="comme4e="9486">9876       s4e=">c48 href="+code=bdev" class="srblock_ev);
9917       *(&->bdedev.c#105        bdev = c49e_hol}t;104
bdeEXPORT_SYMBO37}

 = c49"+codepermk" class="sref"permt10484me="9392">9922      84me=>c49+codestaticKs class="sref"parsnd.c#105closea>);
 9973              e4">9>c49ODE_R id="10470" class="line" nam49ermk" cla4
        structI_BDEV="sref"_kblk_deI_BDEV id="ne" name="9441"lilpblock_device" clilpt9879           _Dapp068lock" class="sr _Dapp068/blo">9879          hos href="fs/block_hos  id=bdev = bdev->c49ache-             9453"= hrefent497s="comme4disck" class="sref"disces4dis>c497s="sref"DISKbdev" class="sref">bde85
        9879           _D5bdev->c49ode=_ded izee" class="sref"=_de15"line" nam5="9399">9979        r5turn 50e_holstaticKlo68sclass="line" name="10ioctllock" class="sree="10ioctl id="10455" class="line" nafileblock_device" clilod_peinclass="line" nafileblock_device" clilod_pe,punsig e  class="line" nacm a href="+code=bcm d_pe,punsig e  lo68sclass="line" naar8lock" class="srar8t *        structI_BDEV="sref"_kblk_deI_BDEV id="ne" name="9441"lileblock_device" clilod_pe">9879           _Dapp068lock" class="sr _Dapp068/blo">9879          hos href="fs/block_hos  id=bdev = 9922      85 id="503k" class="sr9           +code=block_device" class="sref">block_device *        structfileblock_device" clilod_pe">9879           _D59973              e51049350453 */5"comment">5*This routlin checcsswhet5ersa 50isce" class="/* andinvaloiates all 5uffer50ache-eneties ine hatscase.*Tgggggggg* O_NDELAY cs="be altere  us068sfcntl(.., F_SETFL, ..), so we have);
bdev->9879           _ lag    5 People changpin discette5 ine 51e_holer_dire" class="}
/pre>5="line" name="10410>104195/a>block_device *);
bde85
ioctllock" class="sree
ioctlevd="e" class="sref"lass="sref"_kblk_dedgest        5ss="sref">bdev->-5gt;       unsigned >int 5a hre51enhavee totrye tominimize u/a);
* =bdmutex blocin);
}
/pre>5codeDISK_EVENT_MEDIA_CHAN5Ek" c520459Does not tak.ci"mutex4forkev.cwrite ->=bdmute"use.);
->=bdmutex, n>
);
bdevblock_device
aio"writelock" class="sree
aio"write id="10455" class="line" nakiocblock" class="srkiocb+code_kblk_dedgesk" ciocblock" class="sriocb+cod, const"10455" class="line" naioveclock" class="sriovec+code_kblk_dedgesk" cios="sref"_kblk_deios+cod,ef="fs/block_dev.c#10690" i5!comment">5a>->block_device bdev->        structiocblock" class="sriocb+cod">9879          ki_lilpblock_device" cki_lilptblock_deviceblock_device);
*9879          ki_posblock_device" cki_pos="lin720.c#9419" id="9sposblock_device" cpostoff_se<5a> );
);
**9879          ki_posblock_device" cki_pos="lif_dev.c#9319" id="9399" class5_comment">5ref="fs/block_dev.c#104405 id="53isce" class="s="lblock_device);
*block_device(&5!);
  id="v.c#109397" class="lire/a>);
104795                         re/a>);
/a>);
 5 /a>);
5bdev);
comment">5T_SYMBOLt*}

aio"writelock" class="sree
aio"write id=f_dev.c#9319" id="9399" class5>codeik iz5ref="fs/block_dev.c#104505 id="54ache-             9453"= hrefent5z7s="comme5sref"mood4int block_device
aio"rea a href="+code=bee
aio"rea  id="10455" class="line" nakiocblock" class="srkiocb+code_kblk_dedgesk" ciocblock" class="sriocb+cod, const"10455" class="line" naioveclock" class="sriovec+code_kblk_dedgesk" cios="sref"_kblk_deios+cod,ef="fs/block_dev.c#10690" i5zn1);
block_device         structiocblock" class="sriocb+cod">9879          ki_lilpblock_device" cki_lilpt   &ga>        structfileblock_device" clilod_pe">9879           _Dapp068lock" class="sr _Dapp068/blo">9879          hos href="fs/block_hos  id=              9453"= hrefent5cORT_SYMBO5>10410block_device        structi_sizderea a href="+code=bi_sizderea evd="e" class="sref"lae" class="sref"devcgrute" cla>   f_dev.c#9319" id="9399" class50432 *   m5texv_55+code             9453"= hrefent5css="sref"50453" class="line" name="50453>554k" class="srs="l.c#9419" id="9sposblock_device" cpost987ga>        structsizdblock_device" csizdd_pefmcod_se int  * 5*        structiov_shorten="sref"_kblk_deios_shortenevd=""10455" class="line" na"oveclock" class="sriovec+code_)class="line" naios="sref"_kblk_deios+cod,sclass="line" nanr_seg   bdegineric_lile
aio"rea a href="+code=bgineric_lile
aio"rea evd="e" class="sref"iocblock" class="sriocb+cod,pclass="line" naios="sref"_kblk_deios+cod,sclass="line" nanr_seg   10419       >int 5a hre56"+codepermk" class="sref"permt(& !* =bdmutex bloci*"Try496 r lease ahpage associated with ndev.vdref=" whev._devsystem);
);
| = (& !| = block_device >>>>>>>>* hooks: /n5,osee56ss="sref"DISK10455" class="line" nasuper_b);
9879          Dapp068lock" class="srDapp068/blo">9879          hos href="fs/block_hos  id=b    ** bdesuper);
*                if ;<5 href57+code             9453"= hrefent5elass="sre5f="+codechecc_discd ize_e5f="ef57ODE_READe" clbdev" class="sref">bdetry_todfrea_bufferslock" class="srtry_todfrea_buffersevd="e" class="sref"pagea href="+code=bpage id=f_dev.c#9319" id="9399" class5=/a>);
block_deviceef57f="+code= ize.e" class="sref"rea pagea href="+code=brea page="+code= iz/a>        structne
r a pagea href="+code=bne
r a page+cod,ef="fs/block_dev.c#10690" i5eclass="co5id="9478" class="line" no5id=ef579="+code= ize.e" class="sref"writepagea href="+code=bwritepage="+code= i/a>        structne
writepagea href="+code=bne
writepage+cod,ef="fs/block_dev.c#10690" i58"10469" c5 routlin is a wrappersfoc5 ro>c58e_holer_dire".e" class="sref"write_begin="sref"_kblk_dewrite_begin_holer_d/a>        structne
write_begin="sref"_kblk_dene
write_begin+cod,ef="fs/block_dev.c#10690" i58" name="15eal-baccs.  Itdis useds 05eal>c581_holer_dire".e" class="sref"write_en a href="+code=bwrite_en ="+code= i/a>        structne
write_en a href="+code=bne
write_en +cod,ef="fs/block_dev.c#10690" i58=bdincode5810
r leasepage id=,ef="fs/block_dev.c#10690" i58lass="sre5sck" class="sref"gendisce5sck>c584="+code= ize.e" class="sref"direct_IO          structne
direct_IO  );
block_devic"5cla>c58ache-             9453"= hrefent587s="comme5e="9486">9876       s5e=">c58 hrefconst"10455" class="line" nalile
olirationslock" class="srlile
olirationsref">block_device        structne
olin  c589="+code= ize.e" class="sref"a leasea>);
        structne
closea>);
c59e_holer_dire".e" class="sref"llsee>);
        structnev.c#llsee>);
c591_holer_dire".e" class="sref"rea a href="+code=brea evd=codepermk" /a>        structdo"sync"rea a href="+code=bdo"sync"rea  id=,ef="fs/block_dev.c#10690" i59=bdincode5lass="sref"=bget_bisctc592="+code= ize.e" class="sref"write          structdo"sync"write  9922      85me=>c593="+code= ize.e" class="sref"aio"rea a href="+code=baio"rea evd=permk" /a>        structne
aio"rea a href="+code=bee
aio"rea  id=,ef="fs/block_dev.c#10690" i59lass="sre5">9973              e5">9>c594="+code= ize.e" class="sref"aio"writelock" class="sraio"write id=ermk" /a>        structne
aio"writelock" class="sree
aio"write id=,ef="fs/block_dev.c#10690" i59/a>);
        structgineric_lile
mmapblock_device" cgineric_lile
mmap id=,ef="fs/block_dev.c#10690" i59ss="sref"5s="sref">bdev->c596sce" class=".e" class="sref"fsync="sref"_kblk_defsync id=odepermk" /a>        structne
fsync="sref"_kblk_dene
fsync id=,ef="fs/block_dev.c#10690" i597s="comme5disck" class="sref"disces5dis>c597s="sref"DISK.e" class="sref"dev.c#ed
ioctllock" class="srdev.c#ed
ioctld_pe&ga>        structme="10ioctllock" class="sree="10ioctl id=,ef="fs/block_dev.c#10690" i59="10467" 5s="sref">bdev->        structCONFIG_COMPATlock" class="srCONFIG_COMPATche-             9453"= hrefent59class="co5dpust" class="sref"bdpuso5dpu>c599="+code= ize.e" class="sref"compat0ioctllock" class="srcompat0ioctl="+codega>        structcompat085
ioctllock" class="srcompat085
ioctl id=,ef="fs/block_dev.c#10690" i6"line" nam6="9399">9979        r6turn 60e_hol#en ifef="fs/block_dev.c#10690" i6"1ine" nam6=        structgineric_lile
splicdewritelock" class="srgineric_lile
splicdewrite id=,ef="fs/block_dev.c#10690" i6"3ine" nam6=e="9392">9922      86 id="603k" c}_dev.c#9319" id="9399" class6P4RT_SYMBO6t>9973              e61049360453 */6"comment">6*This routlin checcsswhet6ersa 60movabs class="sref"parsnioctl_by_utss="sref"_kblk_deioctl_by_utss id="10455" class="line" name="10455>10454static>int /* andinvaloiates all 6uffer60ache- id="10470" class="line" nam6a7s="comme6tisck" class="sref"disces6n, so607s="sref"DISKs class="sref"parsnre   bdev->block_device6 People changpin discette6 ine 61e_holer_dire"ass="sref"parsnre   }
/pre>6="line" name="10410>104196/a>bdev<   block_device *);
 */6"comment">6ss="sref">bdev->*-6gt;       unsigned >int 6a hre61enhavee totrye tominimize u/aa);
* =bdmutex blocin);
}
/pre>6codeDISK_EVENT_MEDIA_CHAN6Ek" c620459Get a referen=" 96 ev.c_dev.href=" ats@pathDIA_ in ev.ccurrent);
->=bdmute"s="l->=bdmutex,  oev.rwise.);
);
bdev* =bdmutex bloci*n>
6a>->bdev->block_device*}
/pre>6ref="fs/block_dev.c#103006 id="63ss="sck(&off_se<6a> );
bdeERR_PTR  *);
* */6_comment">6ref="fs/block_dev.c#104406 id="63isce" class="ass="sref"parsnerrora href="+code=berrorref" /a>        structkern_patha href="+code=bkern_path id="ne" name="9441"pathDIA_a href="+code=bpathDIA_t bdeERR_PTR  (&6!                 9453"= hrefent6>104796               *                 9453"= hrefent6>a>}
/pre>6lock_dev.c#10400" id="10460" cl641="+code= izes="line" name="9441"S_ISBLK    6 /a>);
6*                 9453"= hrefent6>4a>);
 6T_SYMBOLt*ss="comme6ref="fs/block_dev.c#104506 id="646_holer_dire"ass="sref"parsnerrora href="+code=berrorref" /a/a>*                 9453"= hrefent6>7s="comme6sref"mood4int         structbd_acquirea href="+code=bet_acquire id="ne" name="9441"i class="sref"devcgrdincod_pef              9453"= hrefent6zn1);
 }
/pre>610450" class="line" name=61045065s="line" name="10440>1044910410bdelass="sref"_kblk_dedgest *   m6texv_65+codee" class="sref"faillock" class="srfail>   :             9453"= hrefent6c4a>);
        structERR_PTR  );
int  *6*10454static>i_e" validate0455>10 id="10455" class="line" name="10455>10454static>int block_device);
10419       >int 6a hre66ef="+codeperms class="sref"parsnre   (& !);
| = ->=bdmutex/a);
(& !| = us (    * i
>>>>>>>>* hooks: /n6,osee660488* =bdmutex blociggggggggTTTTTTTT*n>
        if (                 if ;<6 href673k" class="srcodepermbdev<   ef67f="+ca>*10454static>i_e" validate0455>10 id=f              9453"= hrefent6e0480" id=6id="9478" class="line" no6id=ef67ode=_ded izee" class="sref"=_de168"10469" c6 routlin is a wrappersfoc6 ro>c68e_holvoi  class="line" naiterate0utss   c684k" class="srbdev" class="srspin_);
);
 id=f              9453"= hrefent68/a>);
d_pe    *block_devic"6cla>c68E_WRITEk" class="sref10455" class="line" naaddress_9876       s6e=">c68efordparte" class="sref"fordpart68="10467" 6
 id=" id="9397" class="li" class="sref"devcgrdincod_pe    * id=f              9453"= hrefent680480" id=6->c69e_holer_dire" class="lasse" class="sref"Dapp068lock" class="srDapp068/blo    *c691="+code= izelass="sre" classc#9422" id="944spin_dev.c#);
 id=f              9453"= hrefent69=bdincode6lass="sref"=bget_bisctc69ef="+codepermk" classsssssssscomm06ue              9453"= hrefent694329922      86me=>c693k" class="srcodeperm}t;9973              e6">9>c694="+code= izee" classc#9422" id="944_e"g);
);
 id=f              9453"= hrefent69ss="sref"6s="sref">bdev->c69E_WRITEk" class="sreft#9422" id="944spin_dev.c#);
);
 id=f              9453"= hrefent697s="comme6disck" class="sref"disces6dis>c69Ek" class="sref"PAGE_ted(whole>->=bdmutex/a);
bdev->c6904889979        r7turn 70s="comment">* =bdmutex blociggggggggTTTTTTTT* " cla_sb_list_.  We cs=not iput ev.c" cla now asmwe cs=);
->=bdmutggggggggTTTTTTTT* " cla_sb_list_. So we keepsev.creferen=" 9922      87 id="70c_nested(whole>->=bdmutex,ggggggggTTTTTTTT* lat/r.);
9973              e71049370ODE_Rmment">* =bdmutex blociggggggggTTTTTTTT*n>
7*This routlin checcsswhet7ersa 70isce" class="ass="sret#9422" id="944i/* andinvaloiates all 7uffer70E_WRITEk" class="sreft#9422" id="944old
" class="sref"devcgrold
" clatbdev->7 People changpin discette7 ine 71e_holer_dire" class="bdev" class="srspin_);
);
 id=f              9453"= hrefent7"a>}
/pre>7="line" name="10410>104197/a>);
 id=f              9453"= hrefent7"3RT_SYMBO7ass="sref">block_device *);
7ss="sref">bdev->


a/div>

bfoot/r">
Tv.coriginal LXR4s6ftwar" byvev.c;LXR4utexunitytlxr@devux.not
bsubfoot/r">
lxr.devux.no kindly hos ed byv;Redpill Levpro AStof LevuxKconsulm068s