Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 308274 Details for
Bug 449809
gnbd race between sender and receiver process
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch to wait before ending the request, if it is currently being sent.
send_race.patch (text/plain), 3.74 KB, created by
Ben Marzinski
on 2008-06-03 18:25:10 UTC
(
hide
)
Description:
patch to wait before ending the request, if it is currently being sent.
Filename:
MIME Type:
Creator:
Ben Marzinski
Created:
2008-06-03 18:25:10 UTC
Size:
3.74 KB
patch
obsolete
>Index: src/gnbd.c >=================================================================== >--- src.orig/gnbd.c >+++ src/gnbd.c >@@ -264,6 +264,26 @@ static const char *gnbdcmd_to_ascii(int > } > #endif /* NDEBUG */ > >+ >+static int wait_for_send(struct request *req, struct gnbd_device *dev) >+{ >+ DECLARE_WAITQUEUE(wait, current); >+ >+ add_wait_queue(&dev->tx_wait, &wait); >+ while(dev->current_request == req) { >+ set_current_state(TASK_INTERRUPTIBLE); >+ if (signal_pending(current)) { >+ printk(KERN_WARNING "gnbd (pid %d: %s) wait interrupted by signal\n", >+ current->pid, current->comm); >+ return -EINTR; >+ } >+ schedule(); >+ } >+ set_current_state(TASK_RUNNING); >+ remove_wait_queue(&dev->tx_wait, &wait); >+ return 0; >+} >+ > static void gnbd_end_request(struct request *req) > { > int uptodate = (req->errors == 0) ? 1 : 0; >@@ -393,13 +413,14 @@ int __gnbd_send_req(struct gnbd_device * > gnbdcmd_to_ascii(gnbd_cmd(req)), > (unsigned long long)req->sector << 9, > req->nr_sectors << 9); >+ dev->current_request = req; > result = sock_xmit(sock, 1, &request, sizeof(request), > (gnbd_cmd(req) == GNBD_CMD_WRITE)? MSG_MORE: 0, > can_signal); > if (result < 0) { > printk(KERN_ERR "%s: Send control failed (result %d)\n", > dev->disk->disk_name, result); >- goto error_out; >+ goto send_error_out; > } > > if (gnbd_cmd(req) == GNBD_CMD_WRITE) { >@@ -423,14 +444,19 @@ int __gnbd_send_req(struct gnbd_device * > printk(KERN_ERR "%s: Send data failed (result %d)\n", > dev->disk->disk_name, > result); >- goto error_out; >+ goto send_error_out; > } > } > } > } >+ dev->current_request = NULL; >+ wake_up(&dev->tx_wait); > up(&dev->tx_lock); > return 0; > >+send_error_out: >+ dev->current_request = NULL; >+ wake_up(&dev->tx_wait); > error_out: > up(&dev->tx_lock); > return result; >@@ -527,6 +553,9 @@ int gnbd_do_it(struct gnbd_device *dev) > return result; > } > remove_req: >+ result = wait_for_send(req, dev); >+ if (result != 0) >+ return result; > spin_lock(&dev->queue_lock); > list_del_init(&req->queuelist); > dev->last_received = jiffies; >@@ -539,8 +568,9 @@ remove_req: > return result; > } > >-void gnbd_clear_que(struct gnbd_device *dev) >+int gnbd_clear_que(struct gnbd_device *dev) > { >+ int err; > struct request *req; > > BUG_ON(dev->magic != GNBD_MAGIC); >@@ -549,6 +579,9 @@ void gnbd_clear_que(struct gnbd_device * > req = NULL; > if (!list_empty(&dev->queue_head)) { > req = list_entry(dev->queue_head.next, struct request, queuelist); >+ err = wait_for_send(req, dev); >+ if (err) >+ return err; > list_del_init(&req->queuelist); > } > if (req && req != &ping_req) { >@@ -556,6 +589,8 @@ void gnbd_clear_que(struct gnbd_device * > gnbd_end_request(req); > } > } while (req); >+ >+ return 0; > } > > /* >@@ -709,7 +744,9 @@ static int gnbd_ctl_ioctl(struct inode * > if (down_interruptible(&dev->do_it_lock)) > return -EBUSY; > dev->receiver_pid = -1; >- gnbd_clear_que(dev); >+ error = gnbd_clear_que(dev); >+ if (error) >+ return error; > bdev = dev->bdev; > if (bdev) { > blk_run_queue(dev->disk->queue); >@@ -949,6 +986,8 @@ static int __init gnbd_init(void) > INIT_LIST_HEAD(&gnbd_dev[i].queue_head); > init_MUTEX(&gnbd_dev[i].tx_lock); > init_MUTEX(&gnbd_dev[i].do_it_lock); >+ init_waitqueue_head(&gnbd_dev[i].tx_wait); >+ gnbd_dev[i].current_request = NULL; > gnbd_dev[i].class_dev.class = &gnbd_class; > sprintf(gnbd_dev[i].class_dev.class_id, "gnbd%d", i); > err = class_device_register(&gnbd_dev[i].class_dev); >Index: src/gnbd.h >=================================================================== >--- src.orig/gnbd.h >+++ src/gnbd.h >@@ -56,6 +56,8 @@ struct gnbd_device { > char name[32]; > unsigned long last_received; > struct block_device *bdev; >+ struct request *current_request; >+ wait_queue_head_t tx_wait; > }; > > #endif /* __KERNEL__ */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 449809
: 308274