[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4851A9FA.1000104@gmail.com>
Date: Fri, 13 Jun 2008 00:58:01 +0200 (MEST)
From: Andrea Righi <righi.andrea@...il.com>
To: Eduard - Gabriel Munteanu <eduard.munteanu@...ux360.ro>
Cc: tzanussi@...il.com, penberg@...helsinki.fi,
akpm@...ux-foundation.org, compudj@...stal.dyndns.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] relay: Fix race condition which occurs when reading
across CPUs.
Eduard - Gabriel Munteanu wrote:
> @@ -1028,15 +1032,19 @@ static ssize_t relay_file_read_subbufs(struct file *filp, loff_t *ppos,
> break;
>
> avail = min(desc->count, avail);
> + /* subbuf_actor may sleep, so release the spinlock for now */
> + spin_unlock_irqrestore(&buf->rw_lock, flags);
> ret = subbuf_actor(read_start, buf, avail, desc, actor);
> if (desc->error < 0)
> break;
If you just break here buf->rw_lock will be unlocked twice. Maybe a
better way is:
if (desc->error < 0)
goto out;
...
} while (desc->count && ret);
spin_unlock_irqrestore(&buf->rw_lock, flags);
out:
mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex);
return desc->written;
> + spin_lock_irqsave(&buf->rw_lock, flags);
>
> if (ret) {
> relay_file_read_consume(buf, read_start, ret);
> *ppos = relay_file_read_end_pos(buf, read_start, ret);
> }
> } while (desc->count && ret);
> + spin_unlock_irqrestore(&buf->rw_lock, flags);
> mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex);
>
> return desc->written;
-Andrea
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists