Re: [PATCH v2 1/3] brd: extend the rcu regions to cover read and write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Index: linux-2.6/drivers/block/brd.c
> ===================================================================
> --- linux-2.6.orig/drivers/block/brd.c
> +++ linux-2.6/drivers/block/brd.c
> @@ -150,23 +150,27 @@ static void copy_to_brd(struct brd_devic
>  	size_t copy;
>  
>  	copy = min_t(size_t, n, PAGE_SIZE - offset);
> +	rcu_read_lock();
>  	page = brd_lookup_page(brd, sector);

xa_load() inside brd_lookup_page() also calls rcu read lock. Instead of
nesting rcu locks, could we modify the brd_lookup_page to use:

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 970bd6ff38c4..acc37bfdd181 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -55,7 +55,9 @@ static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
        struct page *page;
 
        idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */
-       page = xa_load(&brd->brd_pages, idx);
+
+       XA_STATE(xas, &brd->brd_pages, idx);
+       page = xas_load(&xas);
 
        BUG_ON(page && page->index != idx);

>  	BUG_ON(!page);
>  
>  	dst = kmap_atomic(page);
>  	memcpy(dst + offset, src, copy);
>  	kunmap_atomic(dst);



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux