Skip to content

Commit

Permalink
Add debugging; fix sector registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dacut committed Jun 14, 2016
1 parent f3d6c53 commit 97fbd20
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/ublkdev-c++/s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ void UBDS3Volume::createVolume(
{
milliseconds sleep_time(100);

m_size = size;
m_block_size = blockSize;
m_encryption = encryption;
m_policy = policy;
Expand Down
18 changes: 17 additions & 1 deletion src/ublkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ static long ubdctl_ioctl_register(
dev->n_control_handles = 0;
dev->n_block_handles = 0;

ubd_debug("Registering %s with %llu sectors", info.ubd_name,
(long long unsigned) info.ubd_nsectors);

// Flush everything before the work function might start.
smp_wmb();

Expand Down Expand Up @@ -1365,7 +1368,9 @@ static void ubdblk_add_disk(struct work_struct *work) {

BUG_ON(dev == NULL);

/* Go from registering to running+adding */
ubd_debug("Adding disk %.*s", DISK_NAME_LEN, dev->disk->disk_name);

/* Go from registering to running */
spin_lock_irqsave(&dev->wait.lock, lock_flags);
status = ACCESS_ONCE(dev->status);
BUG_ON(status != UBD_STATUS_REGISTERING);
Expand All @@ -1377,6 +1382,8 @@ static void ubdblk_add_disk(struct work_struct *work) {
/* Add the disk to the system. */
add_disk(dev->disk);

ubd_debug("Added disk %.*s", DISK_NAME_LEN, dev->disk->disk_name);

return;
}

Expand All @@ -1394,6 +1401,8 @@ static void ubdblk_handle_request(struct request_queue *rq) {
spin_lock_irqsave(&dev->wait.lock, lock_flags);
status = dev->status;

ubd_debug("Handling a request");

if (unlikely(status == UBD_STATUS_TERMINATED)) {
// Device is not running; fail the request.
ubd_warning("Received a request for a non-running device.");
Expand Down Expand Up @@ -1430,6 +1439,13 @@ static void ubdblk_handle_fs_request(

tail = ACCESS_ONCE(dev->pending_delivery_tail);

ubd_debug("ubdblk_handle_fs_request: queueing %s request for sector %llu to %llu",
((req->cmd_flags & REQ_DISCARD) ? "discard" :
(req->cmd_flags & REQ_FLUSH) ? "flush" :
(rq_data_dir(req) == READ) ? "read" : "write"),
(long long unsigned) blk_rq_pos(req),
(long long unsigned) blk_rq_sectors(req));

ACCESS_ONCE(dev->pending_delivery_tail) = req;
if (tail == NULL) {
ACCESS_ONCE(dev->pending_delivery_head) = req;
Expand Down

0 comments on commit 97fbd20

Please sign in to comment.