Elias Oltmanns wrote: > Pavel Machek wrote: >> On Fri 2008-03-07 19:26:41, Elias Oltmanns wrote: >>> This patch provides a generic way to freeze the request queue of a block >>> device temporarily. This functionality is exposed to user space via sysfs. >>> >>> Signed-off-by: Elias Oltmanns [...] >>> +/* >>> + * When reading the 'protect' attribute, we return seconds remaining >>> + * before the unfreeze timeout expires. >>> + */ >>> +static ssize_t queue_protect_show(struct request_queue *q, char *page) >>> +{ >>> + unsigned int seconds = 0; >>> + >>> + if (blk_queue_stopped(q) && timer_pending(&q->unfreeze_timer)) >>> + /* >>> + * Adding 1 in order to guarantee nonzero value until timer >>> + * has actually expired. >>> + */ >>> + seconds = jiffies_to_msecs(q->unfreeze_timer.expires >>> + - jiffies) / 1000 + 1; >> >> Is it okay to read expires without locking? > > No, I have been a bit careless with regard to locking in this patch. See > the revised version below. Come to think of it, the lock really shouldn't be released between modding / checking the timer and issuing the respective command. This makes the whole thing a bit messy because allocating a request the standard way is done before acquiring the spin_lock. Since we don't know at that time whether a command is actually going to be enqueued, this looks rather suboptimal to me. A better idea anyone? Regards, Elias