[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-bcache
Subject:    Re: How to understand statements on FIFO j->pin in bch_journal_next
From:       Kent Overstreet <kent.overstreet () gmail ! com>
Date:       2018-06-28 9:25:10
Message-ID: 20180628092510.GA21561 () kmo-pixel
[Download RAW message or body]

On Thu, Jun 28, 2018 at 04:22:56PM +0800, Wang Sheng-Hui wrote:
> Hi,
> 
> Sorry to trouble you.
> 
> I noticed some statements in the function:
> ---------------------------------------------------------
> void bch_journal_next(struct journal *j)
> {
>     atomic_t p = { 1 };
>     ...
>     BUG_ON(!fifo_push(&j->pin, p));
>     atomic_set(&fifo_back(&j->pin), 1);
> 
>     ...
> 
> fifo_push would add atomic_t {1} to the back of the FIFO, while next
> atomic_set would set the back element of FIFO to 1, which is atomic_t {1}.
> 
> I wonder why there is additional atomic_set statement ?

Because the first fifo_push() isn't an atomic.
--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic