示例#1
0
void
xfs_relse_buftarg(
	xfs_buftarg_t		*btp)
{
	invalidate_bdev(btp->pbr_bdev, 1);
	truncate_inode_pages(btp->pbr_mapping, 0LL);
}
示例#2
0
文件: tbio.c 项目: ystk/debian-ltp
static void tbio_exit(void)
{
	if(Device.bdev) {
		invalidate_bdev(Device.bdev,1);
		bdput(Device.bdev);
	}

	del_gendisk(Device.gd);
	put_disk(Device.gd);
	unregister_blkdev(TBIO_MAJOR , "tbio");
	vfree(Device.data);
}
示例#3
0
static int vbc_blk_access(struct page *page, sector_t sector, bool is_read)
{
	struct block_device *bdev;
	struct bio *bio;
	int err, rq;
	fmode_t devmode = is_read ? FMODE_READ : FMODE_WRITE;

	bdev = vbc_blk_get_device(config.phandle, devmode);
	if (IS_ERR(bdev)) {
		pr_err("could not open block dev\n");
		return PTR_ERR(bdev);
	}

	/* map the sector to page */
	bio = bio_alloc(GFP_NOIO, 1);
	if (!bio) {
		err = -ENOMEM;
		goto unwind_bdev;
	}
	bio->bi_bdev	= bdev;
	bio->bi_sector	= sector;
	bio->bi_vcnt	= 1;
	bio->bi_idx	= 0;
	bio->bi_size	= SECTOR_SIZE;
	bio->bi_io_vec[0].bv_page	= page;
	bio->bi_io_vec[0].bv_len	= SECTOR_SIZE;
	bio->bi_io_vec[0].bv_offset	= 0;

	/* submit bio */
	rq = REQ_SYNC | REQ_SOFTBARRIER | REQ_NOIDLE;
	if (!is_read)
		rq |= REQ_WRITE;

	vbc_blk_submit_bio(bio, rq);

	/* vbc_blk_endio passes up any error in bi_private */
	err = (int)bio->bi_private;
	bio_put(bio);

unwind_bdev:
	if (!is_read) {
		fsync_bdev(bdev);
		invalidate_bdev(bdev);
	}
	blkdev_put(bdev, devmode);

	return err;
}
示例#4
0
/* Kill _all_ buffers, dirty or not.. */
static void kill_bdev(struct block_device *bdev)
{
	invalidate_bdev(bdev, 1);
	truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
}	
示例#5
0
/*
 * Look for various forms of IDE disk geometry translation
 */
static int handle_ide_mess(struct block_device *bdev)
{
#ifdef CONFIG_BLK_DEV_IDE
	Sector sect;
	unsigned char *data;
	kdev_t dev = to_kdev_t(bdev->bd_dev);
	unsigned int sig;
	int heads = 0;
	struct partition *p;
	int i;
	/*
	 * The i386 partition handling programs very often
	 * make partitions end on cylinder boundaries.
	 * There is no need to do so, and Linux fdisk doesnt always
	 * do this, and Windows NT on Alpha doesnt do this either,
	 * but still, this helps to guess #heads.
	 */
	data = read_dev_sector(bdev, 0, &sect);
	if (!data)
		return -1;
	if (!msdos_magic_present(data + 510)) {
		put_dev_sector(sect);
		return 0;
	}
	sig = le16_to_cpu(*(unsigned short *)(data + 2));
	p = (struct partition *) (data + 0x1be);
	for (i = 0; i < 4; i++) {
		struct partition *q = &p[i];
		if (NR_SECTS(q)) {
			if ((q->sector & 63) == 1 &&
			    (q->end_sector & 63) == 63)
				heads = q->end_head + 1;
			break;
		}
	}
	if (SYS_IND(p) == EZD_PARTITION) {
		/*
		 * Accesses to sector 0 must go to sector 1 instead.
		 */
		if (ide_xlate_1024(dev, -1, heads, " [EZD]"))
			goto reread;
	} else if (SYS_IND(p) == DM6_PARTITION) {

		/*
		 * Everything on the disk is offset by 63 sectors,
		 * including a "new" MBR with its own partition table.
		 */
		if (ide_xlate_1024(dev, 1, heads, " [DM6:DDO]"))
			goto reread;
	} else if (sig <= 0x1ae &&
		   data[sig] == 0xAA && data[sig+1] == 0x55 &&
		   (data[sig+2] & 1)) {
		/* DM6 signature in MBR, courtesy of OnTrack */
		(void) ide_xlate_1024 (dev, 0, heads, " [DM6:MBR]");
	} else if (SYS_IND(p) == DM6_AUX1PARTITION ||
		   SYS_IND(p) == DM6_AUX3PARTITION) {
		/*
		 * DM6 on other than the first (boot) drive
		 */
		(void) ide_xlate_1024(dev, 0, heads, " [DM6:AUX]");
	} else {
		(void) ide_xlate_1024(dev, 2, heads, " [PTBL]");
	}
	put_dev_sector(sect);
	return 1;

reread:
	put_dev_sector(sect);
	/* Flush the cache */
	invalidate_bdev(bdev, 1);
	truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
#endif /* CONFIG_BLK_DEV_IDE */
	return 1;
}