Merge tag 'dax-fix-5.2-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Jul 2019 02:32:11 +0000 (11:32 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Jul 2019 02:32:11 +0000 (11:32 +0900)
Pull dax fix from Dan Williams:
 "A single dax fix that has been soaking awaiting other fixes under
  discussion to join it. As it is getting late in the cycle lets proceed
  with this fix and save follow-on changes for post-v5.3-rc1.

   - Fix xarray entry association for mixed mappings"

* tag 'dax-fix-5.2-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
  dax: Fix xarray entry association for mixed mappings

1  2 
fs/dax.c

diff --combined fs/dax.c
+++ b/fs/dax.c
@@@ -1,9 -1,17 +1,9 @@@
 +// SPDX-License-Identifier: GPL-2.0-only
  /*
   * fs/dax.c - Direct Access filesystem code
   * Copyright (c) 2013-2014 Intel Corporation
   * Author: Matthew Wilcox <matthew.r.wilcox@intel.com>
   * Author: Ross Zwisler <ross.zwisler@linux.intel.com>
 - *
 - * This program is free software; you can redistribute it and/or modify it
 - * under the terms and conditions of the GNU General Public License,
 - * version 2, as published by the Free Software Foundation.
 - *
 - * This program is distributed in the hope it will be useful, but WITHOUT
 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 - * more details.
   */
  
  #include <linux/atomic.h>
@@@ -720,12 -728,11 +720,11 @@@ static void *dax_insert_entry(struct xa
  
        xas_reset(xas);
        xas_lock_irq(xas);
-       if (dax_entry_size(entry) != dax_entry_size(new_entry)) {
+       if (dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) {
+               void *old;
                dax_disassociate_entry(entry, mapping, false);
                dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address);
-       }
-       if (dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) {
                /*
                 * Only swap our new entry into the page cache if the current
                 * entry is a zero page or an empty entry.  If a normal PTE or
                 * existing entry is a PMD, we will just leave the PMD in the
                 * tree and dirty it if necessary.
                 */
-               void *old = dax_lock_entry(xas, new_entry);
+               old = dax_lock_entry(xas, new_entry);
                WARN_ON_ONCE(old != xa_mk_value(xa_to_value(entry) |
                                        DAX_LOCKED));
                entry = new_entry;