| To: | Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH v5 4/7] dax: add support for fsync/sync |
| From: | Dan Williams <dan.j.williams@xxxxxxxxx> |
| Date: | Sat, 19 Dec 2015 10:37:46 -0800 |
| Cc: | "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, "J. Bruce Fields" <bfields@xxxxxxxxxxxx>, "Theodore Ts'o" <tytso@xxxxxxx>, Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>, Andreas Dilger <adilger.kernel@xxxxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Jan Kara <jack@xxxxxxxx>, Jeff Layton <jlayton@xxxxxxxxxxxxxxx>, Matthew Wilcox <willy@xxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, linux-ext4 <linux-ext4@xxxxxxxxxxxxxxx>, linux-fsdevel <linux-fsdevel@xxxxxxxxxxxxxxx>, Linux MM <linux-mm@xxxxxxxxx>, "linux-nvdimm@xxxxxxxxxxxx" <linux-nvdimm@xxxxxxxxxxxx>, X86 ML <x86@xxxxxxxxxx>, XFS Developers <xfs@xxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> |
| Delivered-to: | xfs@xxxxxxxxxxx |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FSmezClG81MH61FDP2ySVT/MDS1NRCa+nMiAgcPSV1k=; b=mmLYHc4l2lDt9f5VmvK1fZrCzn7Xg35GbBrxNnf0hATiOMD5ND3gTm7J42SRDjE9ya k7bDrh3oCyiCJeCL13lxmhpWPY2soAjrcv5/uDV3mLOeYJW3+NRa4zvBb4SPzqaRImrh BDLOOc+jB8nKRpLtg9Lz6xRqxQkB/DYTNvihGWK6QTcGcTthCxxf8jlpnzkdWxi+z7dI Z+u36c8wKocNHLqLkmCPmm3cP+S6XObULfe5VAC8mPNFm0x3prz8XYyHM6v37GQPnPcb Rg4VjiDnnYCbuhhlqYmMJudZqZqvMgRPF+lk9rMFfCfoh+QcrHTvcvRfP5estwNzwHlh RCEg== |
| In-reply-to: | <1450502540-8744-5-git-send-email-ross.zwisler@xxxxxxxxxxxxxxx> |
| References: | <1450502540-8744-1-git-send-email-ross.zwisler@xxxxxxxxxxxxxxx> <1450502540-8744-5-git-send-email-ross.zwisler@xxxxxxxxxxxxxxx> |
On Fri, Dec 18, 2015 at 9:22 PM, Ross Zwisler
<ross.zwisler@xxxxxxxxxxxxxxx> wrote:
> To properly handle fsync/msync in an efficient way DAX needs to track dirty
> pages so it is able to flush them durably to media on demand.
>
> The tracking of dirty pages is done via the radix tree in struct
> address_space. This radix tree is already used by the page writeback
> infrastructure for tracking dirty pages associated with an open file, and
> it already has support for exceptional (non struct page*) entries. We
> build upon these features to add exceptional entries to the radix tree for
> DAX dirty PMD or PTE pages at fault time.
>
> Signed-off-by: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>
[..]
> +static void dax_writeback_one(struct address_space *mapping, pgoff_t index,
> + void *entry)
> +{
> + struct radix_tree_root *page_tree = &mapping->page_tree;
> + int type = RADIX_DAX_TYPE(entry);
> + struct radix_tree_node *node;
> + void **slot;
> +
> + if (type != RADIX_DAX_PTE && type != RADIX_DAX_PMD) {
> + WARN_ON_ONCE(1);
> + return;
> + }
> +
> + spin_lock_irq(&mapping->tree_lock);
> + /*
> + * Regular page slots are stabilized by the page lock even
> + * without the tree itself locked. These unlocked entries
> + * need verification under the tree lock.
> + */
> + if (!__radix_tree_lookup(page_tree, index, &node, &slot))
> + goto unlock;
> + if (*slot != entry)
> + goto unlock;
> +
> + /* another fsync thread may have already written back this entry */
> + if (!radix_tree_tag_get(page_tree, index, PAGECACHE_TAG_TOWRITE))
> + goto unlock;
> +
> + radix_tree_tag_clear(page_tree, index, PAGECACHE_TAG_TOWRITE);
> +
> + if (type == RADIX_DAX_PMD)
> + wb_cache_pmem(RADIX_DAX_ADDR(entry), PMD_SIZE);
> + else
> + wb_cache_pmem(RADIX_DAX_ADDR(entry), PAGE_SIZE);
Hi Ross, I should have realized this sooner, but what guarantees that
the address returned by RADIX_DAX_ADDR(entry) is still valid at this
point? I think we need to store the sector in the radix tree and then
perform a new dax_map_atomic() operation to either lookup a valid
address or fail the sync request. Otherwise, if the device is gone
we'll crash, or write into some other random vmalloc address space.
|
| Previous by Date: | RE: WE CAN SUPPLY CHEAPESTttt SHIP COSTttt DOOR TO DOOR BY AIR IF YOU HAVE GOODS IN CHINA, frank@xxxxxxxxxxxxxxxx |
|---|---|
| Next by Date: | [PATCH] XFS: Use a signed return type for suffix_kstrtoint(), SF Markus Elfring |
| Previous by Thread: | [PATCH v5 4/7] dax: add support for fsync/sync, Ross Zwisler |
| Next by Thread: | Re: [PATCH v5 4/7] dax: add support for fsync/sync, Ross Zwisler |
| Indexes: | [Date] [Thread] [Top] [All Lists] |