};
struct lloop_device {
- int lo_number;
- int lo_refcnt;
- loff_t lo_offset;
- loff_t lo_sizelimit;
- int lo_flags;
- int (*ioctl)(struct lloop_device *, int cmd,
- unsigned long arg);
+ int lo_number;
+ int lo_refcnt;
+ loff_t lo_offset;
+ loff_t lo_sizelimit;
+ int lo_flags;
+ int (*ioctl)(struct lloop_device *, int cmd,
+ unsigned long arg);
- struct file *lo_backing_file;
- struct block_device *lo_device;
- unsigned lo_blocksize;
+ struct file *lo_backing_file;
+ struct block_device *lo_device;
+ unsigned lo_blocksize;
- int old_gfp_mask;
+ int old_gfp_mask;
spinlock_t lo_lock;
struct bio *lo_bio;
int lo_state;
struct semaphore lo_sem;
struct mutex lo_ctl_mutex;
- cfs_atomic_t lo_pending;
- cfs_waitq_t lo_bh_wait;
+ atomic_t lo_pending;
+ wait_queue_head_t lo_bh_wait;
- struct request_queue *lo_queue;
+ struct request_queue *lo_queue;
- const struct lu_env *lo_env;
- struct cl_io lo_io;
- struct ll_dio_pages lo_pvec;
+ const struct lu_env *lo_env;
+ struct cl_io lo_io;
+ struct ll_dio_pages lo_pvec;
- /* data to handle bio for lustre. */
- struct lo_request_data {
- struct page *lrd_pages[LLOOP_MAX_SEGMENTS];
- loff_t lrd_offsets[LLOOP_MAX_SEGMENTS];
- } lo_requests[1];
+ /* data to handle bio for lustre. */
+ struct lo_request_data {
+ struct page *lrd_pages[LLOOP_MAX_SEGMENTS];
+ loff_t lrd_offsets[LLOOP_MAX_SEGMENTS];
+ } lo_requests[1];
};
/*
lo->lo_bio = lo->lo_biotail = bio;
spin_unlock_irqrestore(&lo->lo_lock, flags);
- cfs_atomic_inc(&lo->lo_pending);
- if (cfs_waitq_active(&lo->lo_bh_wait))
- cfs_waitq_signal(&lo->lo_bh_wait);
+ atomic_inc(&lo->lo_pending);
+ if (waitqueue_active(&lo->lo_bh_wait))
+ wake_up(&lo->lo_bh_wait);
}
/*
loop_add_bio(lo, old_bio);
LL_MRF_RETURN(0);
err:
- cfs_bio_io_error(old_bio, old_bio->bi_size);
+ bio_io_error(old_bio);
LL_MRF_RETURN(0);
}
while (bio) {
struct bio *tmp = bio->bi_next;
bio->bi_next = NULL;
- cfs_bio_endio(bio, bio->bi_size, ret);
+ bio_endio(bio, ret);
bio = tmp;
}
}
static inline int loop_active(struct lloop_device *lo)
{
- return cfs_atomic_read(&lo->lo_pending) ||
- (lo->lo_state == LLOOP_RUNDOWN);
+ return atomic_read(&lo->lo_pending) ||
+ (lo->lo_state == LLOOP_RUNDOWN);
}
/*
up(&lo->lo_sem);
for (;;) {
- cfs_wait_event(lo->lo_bh_wait, loop_active(lo));
- if (!cfs_atomic_read(&lo->lo_pending)) {
+ wait_event(lo->lo_bh_wait, loop_active(lo));
+ if (!atomic_read(&lo->lo_pending)) {
int exiting = 0;
spin_lock_irq(&lo->lo_lock);
exiting = (lo->lo_state == LLOOP_RUNDOWN);
} else {
times++;
}
- if ((times & 127) == 0) {
- CDEBUG(D_INFO, "total: %lu, count: %lu, avg: %lu\n",
- total_count, times, total_count / times);
- }
-
- LASSERT(bio != NULL);
- LASSERT(count <= cfs_atomic_read(&lo->lo_pending));
- loop_handle_bio(lo, bio);
- cfs_atomic_sub(count, &lo->lo_pending);
- }
- cl_env_put(env, &refcheck);
+ if ((times & 127) == 0) {
+ CDEBUG(D_INFO, "total: %lu, count: %lu, avg: %lu\n",
+ total_count, times, total_count / times);
+ }
+
+ LASSERT(bio != NULL);
+ LASSERT(count <= atomic_read(&lo->lo_pending));
+ loop_handle_bio(lo, bio);
+ atomic_sub(count, &lo->lo_pending);
+ }
+ cl_env_put(env, &refcheck);
out:
up(&lo->lo_sem);
- return ret;
+ return ret;
}
static int loop_set_fd(struct lloop_device *lo, struct file *unused,
int error;
loff_t size;
- if (!cfs_try_module_get(THIS_MODULE))
- return -ENODEV;
+ if (!try_module_get(THIS_MODULE))
+ return -ENODEV;
error = -EBUSY;
if (lo->lo_state != LLOOP_UNBOUND)
#endif
/* queue parameters */
- CLASSERT(PAGE_CACHE_SIZE < (1 << (sizeof(unsigned short) * 8)));
- blk_queue_logical_block_size(lo->lo_queue,
- (unsigned short)PAGE_CACHE_SIZE);
blk_queue_max_hw_sectors(lo->lo_queue,
LLOOP_MAX_SEGMENTS << (PAGE_CACHE_SHIFT - 9));
blk_queue_max_segments(lo->lo_queue, LLOOP_MAX_SEGMENTS);
return 0;
out:
- /* This is safe: open() is still holding a reference. */
- cfs_module_put(THIS_MODULE);
- return error;
+ /* This is safe: open() is still holding a reference. */
+ module_put(THIS_MODULE);
+ return error;
}
static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
spin_lock_irq(&lo->lo_lock);
lo->lo_state = LLOOP_RUNDOWN;
spin_unlock_irq(&lo->lo_lock);
- cfs_waitq_signal(&lo->lo_bh_wait);
+ wake_up(&lo->lo_bh_wait);
down(&lo->lo_sem);
lo->lo_backing_file = NULL;
bd_set_size(bdev, 0);
mapping_set_gfp_mask(filp->f_mapping, gfp);
lo->lo_state = LLOOP_UNBOUND;
- fput(filp);
- /* This is safe: open() is still holding a reference. */
- cfs_module_put(THIS_MODULE);
- return 0;
+ fput(filp);
+ /* This is safe: open() is still holding a reference. */
+ module_put(THIS_MODULE);
+ return 0;
}
static int lo_open(struct block_device *bdev, fmode_t mode)
return 0;
}
-static int lo_release(struct gendisk *disk, fmode_t mode)
+#ifdef HAVE_BLKDEV_RELEASE_RETURN_INT
+static int
+#else
+static void
+#endif
+lo_release(struct gendisk *disk, fmode_t mode)
{
- struct lloop_device *lo = disk->private_data;
+ struct lloop_device *lo = disk->private_data;
mutex_lock(&lo->lo_ctl_mutex);
- --lo->lo_refcnt;
+ --lo->lo_refcnt;
mutex_unlock(&lo->lo_ctl_mutex);
-
- return 0;
+#ifdef HAVE_BLKDEV_RELEASE_RETURN_INT
+ return 0;
+#endif
}
/* lloop device node's ioctl function. */
case LL_IOC_LLOOP_INFO: {
struct lu_fid fid;
- LASSERT(lo->lo_backing_file != NULL);
+ if (lo->lo_backing_file == NULL) {
+ err = -ENOENT;
+ break;
+ }
if (inode == NULL)
inode = lo->lo_backing_file->f_dentry->d_inode;
if (lo->lo_state == LLOOP_BOUND)
mutex_init(&lo->lo_ctl_mutex);
sema_init(&lo->lo_sem, 0);
- cfs_waitq_init(&lo->lo_bh_wait);
+ init_waitqueue_head(&lo->lo_bh_wait);
lo->lo_number = i;
spin_lock_init(&lo->lo_lock);
disk->major = lloop_major;