Merge tag 'fixes-2020-11-05' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 5 Nov 2020 18:57:01 +0000 (10:57 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 5 Nov 2020 18:57:01 +0000 (10:57 -0800)
Pull highmem initialization fix from Mike Rapoport:
 "Fix highmem initialization on arm and xtensa

  Recent refactoring of memblock iterators has broken initialization of
  highmem on arm and xtensa because it changed the way beginning and end
  of memory regions are rounded to PFNs. This fix restores the original
  behaviour"

* tag 'fixes-2020-11-05' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations

13 files changed:
drivers/pci/controller/dwc/pcie-designware-host.c
drivers/pci/controller/pci-mvebu.c
drivers/pci/pci.c
fs/gfs2/glock.c
fs/gfs2/glops.c
fs/gfs2/glops.h
fs/gfs2/inode.c
fs/gfs2/lops.c
fs/gfs2/lops.h
fs/gfs2/ops_fstype.c
fs/gfs2/recovery.c
fs/gfs2/rgrp.c
fs/gfs2/super.c

index 674f32d..44c2a65 100644 (file)
@@ -586,8 +586,12 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
         * ATU, so we should not program the ATU here.
         */
        if (pp->bridge->child_ops == &dw_child_pcie_ops) {
-               struct resource_entry *entry =
-                       resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
+               struct resource_entry *tmp, *entry = NULL;
+
+               /* Get last memory resource entry */
+               resource_list_for_each_entry(tmp, &pp->bridge->windows)
+                       if (resource_type(tmp->res) == IORESOURCE_MEM)
+                               entry = tmp;
 
                dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX0,
                                          PCIE_ATU_TYPE_MEM, entry->res->start,
index eee8283..ed13e81 100644 (file)
@@ -958,25 +958,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
 }
 
 /*
- * We can't use devm_of_pci_get_host_bridge_resources() because we
- * need to parse our special DT properties encoding the MEM and IO
- * apertures.
+ * devm_of_pci_get_host_bridge_resources() only sets up translateable resources,
+ * so we need extra resource setup parsing our special DT properties encoding
+ * the MEM and IO apertures.
  */
 static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
 {
        struct device *dev = &pcie->pdev->dev;
-       struct device_node *np = dev->of_node;
        struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
        int ret;
 
-       /* Get the bus range */
-       ret = of_pci_parse_bus_range(np, &pcie->busn);
-       if (ret) {
-               dev_err(dev, "failed to parse bus-range property: %d\n", ret);
-               return ret;
-       }
-       pci_add_resource(&bridge->windows, &pcie->busn);
-
        /* Get the PCIe memory aperture */
        mvebu_mbus_get_pcie_mem_aperture(&pcie->mem);
        if (resource_size(&pcie->mem) == 0) {
@@ -986,6 +977,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
 
        pcie->mem.name = "PCI MEM";
        pci_add_resource(&bridge->windows, &pcie->mem);
+       ret = devm_request_resource(dev, &iomem_resource, &pcie->mem);
+       if (ret)
+               return ret;
 
        /* Get the PCIe IO aperture */
        mvebu_mbus_get_pcie_io_aperture(&pcie->io);
@@ -999,9 +993,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
                pcie->realio.name = "PCI I/O";
 
                pci_add_resource(&bridge->windows, &pcie->realio);
+               ret = devm_request_resource(dev, &ioport_resource, &pcie->realio);
+               if (ret)
+                       return ret;
        }
 
-       return devm_request_pci_bus_resources(dev, &bridge->windows);
+       return 0;
 }
 
 /*
index 6d4d5a2..e578d34 100644 (file)
@@ -3516,8 +3516,13 @@ void pci_acs_init(struct pci_dev *dev)
 {
        dev->acs_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
 
-       if (dev->acs_cap)
-               pci_enable_acs(dev);
+       /*
+        * Attempt to enable ACS regardless of capability because some Root
+        * Ports (e.g. those quirked with *_intel_pch_acs_*) do not have
+        * the standard ACS capability but still support ACS via those
+        * quirks.
+        */
+       pci_enable_acs(dev);
 }
 
 /**
index 5441c17..d98a2e5 100644 (file)
@@ -1078,7 +1078,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
 out_free:
        kfree(gl->gl_lksb.sb_lvbptr);
        kmem_cache_free(cachep, gl);
-       atomic_dec(&sdp->sd_glock_disposal);
+       if (atomic_dec_and_test(&sdp->sd_glock_disposal))
+               wake_up(&sdp->sd_glock_wait);
 
 out:
        return ret;
index aa3f523..6c1432d 100644 (file)
@@ -164,6 +164,31 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
                       GFS2_LFC_AIL_FLUSH);
 }
 
+/**
+ * gfs2_rgrp_metasync - sync out the metadata of a resource group
+ * @gl: the glock protecting the resource group
+ *
+ */
+
+static int gfs2_rgrp_metasync(struct gfs2_glock *gl)
+{
+       struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
+       struct address_space *metamapping = &sdp->sd_aspace;
+       struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl);
+       const unsigned bsize = sdp->sd_sb.sb_bsize;
+       loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK;
+       loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1;
+       int error;
+
+       filemap_fdatawrite_range(metamapping, start, end);
+       error = filemap_fdatawait_range(metamapping, start, end);
+       WARN_ON_ONCE(error && !gfs2_withdrawn(sdp));
+       mapping_set_error(metamapping, error);
+       if (error)
+               gfs2_io_error(sdp);
+       return error;
+}
+
 /**
  * rgrp_go_sync - sync out the metadata for this glock
  * @gl: the glock
@@ -176,11 +201,7 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
 static int rgrp_go_sync(struct gfs2_glock *gl)
 {
        struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-       struct address_space *mapping = &sdp->sd_aspace;
        struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl);
-       const unsigned bsize = sdp->sd_sb.sb_bsize;
-       loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK;
-       loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1;
        int error;
 
        if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
@@ -189,10 +210,7 @@ static int rgrp_go_sync(struct gfs2_glock *gl)
 
        gfs2_log_flush(sdp, gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
                       GFS2_LFC_RGRP_GO_SYNC);
-       filemap_fdatawrite_range(mapping, start, end);
-       error = filemap_fdatawait_range(mapping, start, end);
-       WARN_ON_ONCE(error && !gfs2_withdrawn(sdp));
-       mapping_set_error(mapping, error);
+       error = gfs2_rgrp_metasync(gl);
        if (!error)
                error = gfs2_ail_empty_gl(gl);
        gfs2_free_clones(rgd);
@@ -266,7 +284,24 @@ static void gfs2_clear_glop_pending(struct gfs2_inode *ip)
 }
 
 /**
- * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
+ * gfs2_inode_metasync - sync out the metadata of an inode
+ * @gl: the glock protecting the inode
+ *
+ */
+int gfs2_inode_metasync(struct gfs2_glock *gl)
+{
+       struct address_space *metamapping = gfs2_glock2aspace(gl);
+       int error;
+
+       filemap_fdatawrite(metamapping);
+       error = filemap_fdatawait(metamapping);
+       if (error)
+               gfs2_io_error(gl->gl_name.ln_sbd);
+       return error;
+}
+
+/**
+ * inode_go_sync - Sync the dirty metadata of an inode
  * @gl: the glock protecting the inode
  *
  */
@@ -297,8 +332,7 @@ static int inode_go_sync(struct gfs2_glock *gl)
                error = filemap_fdatawait(mapping);
                mapping_set_error(mapping, error);
        }
-       ret = filemap_fdatawait(metamapping);
-       mapping_set_error(metamapping, ret);
+       ret = gfs2_inode_metasync(gl);
        if (!error)
                error = ret;
        gfs2_ail_empty_gl(gl);
index 2dd192e..695898a 100644 (file)
@@ -22,6 +22,7 @@ extern const struct gfs2_glock_operations gfs2_quota_glops;
 extern const struct gfs2_glock_operations gfs2_journal_glops;
 extern const struct gfs2_glock_operations *gfs2_glops_list[];
 
+extern int gfs2_inode_metasync(struct gfs2_glock *gl);
 extern void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync);
 
 #endif /* __GLOPS_DOT_H__ */
index 6774865..077ccb1 100644 (file)
@@ -180,7 +180,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
                error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
                if (unlikely(error))
                        goto fail;
-               gfs2_cancel_delete_work(ip->i_iopen_gh.gh_gl);
+               if (blktype != GFS2_BLKST_UNLINKED)
+                       gfs2_cancel_delete_work(ip->i_iopen_gh.gh_gl);
                glock_set_object(ip->i_iopen_gh.gh_gl, ip);
                gfs2_glock_put(io_gl);
                io_gl = NULL;
index ed69298..3922b26 100644 (file)
@@ -22,6 +22,7 @@
 #include "incore.h"
 #include "inode.h"
 #include "glock.h"
+#include "glops.h"
 #include "log.h"
 #include "lops.h"
 #include "meta_io.h"
@@ -817,41 +818,19 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
        return error;
 }
 
-/**
- * gfs2_meta_sync - Sync all buffers associated with a glock
- * @gl: The glock
- *
- */
-
-void gfs2_meta_sync(struct gfs2_glock *gl)
-{
-       struct address_space *mapping = gfs2_glock2aspace(gl);
-       struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-       int error;
-
-       if (mapping == NULL)
-               mapping = &sdp->sd_aspace;
-
-       filemap_fdatawrite(mapping);
-       error = filemap_fdatawait(mapping);
-
-       if (error)
-               gfs2_io_error(gl->gl_name.ln_sbd);
-}
-
 static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
        if (error) {
-               gfs2_meta_sync(ip->i_gl);
+               gfs2_inode_metasync(ip->i_gl);
                return;
        }
        if (pass != 1)
                return;
 
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
                jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
@@ -1060,14 +1039,14 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
        if (error) {
-               gfs2_meta_sync(ip->i_gl);
+               gfs2_inode_metasync(ip->i_gl);
                return;
        }
        if (pass != 1)
                return;
 
        /* data sync? */
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
                jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
index 4a3d8ae..fbdbb08 100644 (file)
@@ -27,8 +27,6 @@ extern void gfs2_log_submit_bio(struct bio **biop, int opf);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
 extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
                           struct gfs2_log_header_host *head, bool keep_cache);
-extern void gfs2_meta_sync(struct gfs2_glock *gl);
-
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
 {
        unsigned int limit;
index 7a7e3c1..61fce59 100644 (file)
@@ -633,8 +633,10 @@ static int init_statfs(struct gfs2_sbd *sdp)
        if (IS_ERR(sdp->sd_statfs_inode)) {
                error = PTR_ERR(sdp->sd_statfs_inode);
                fs_err(sdp, "can't read in statfs inode: %d\n", error);
-               goto fail;
+               goto out;
        }
+       if (sdp->sd_args.ar_spectator)
+               goto out;
 
        pn = gfs2_lookup_simple(master, "per_node");
        if (IS_ERR(pn)) {
@@ -682,15 +684,17 @@ free_local:
        iput(pn);
 put_statfs:
        iput(sdp->sd_statfs_inode);
-fail:
+out:
        return error;
 }
 
 /* Uninitialize and free up memory used by the list of statfs inodes */
 static void uninit_statfs(struct gfs2_sbd *sdp)
 {
-       gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
-       free_local_statfs_inodes(sdp);
+       if (!sdp->sd_args.ar_spectator) {
+               gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
+               free_local_statfs_inodes(sdp);
+       }
        iput(sdp->sd_statfs_inode);
 }
 
@@ -704,7 +708,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
 
        if (undo) {
                jindex = 0;
-               goto fail_jinode_gh;
+               goto fail_statfs;
        }
 
        sdp->sd_jindex = gfs2_lookup_simple(master, "jindex");
index b5cbe21..c26c68e 100644 (file)
@@ -349,7 +349,7 @@ static int update_statfs_inode(struct gfs2_jdesc *jd,
 
        mark_buffer_dirty(bh);
        brelse(bh);
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
 out:
        return error;
index ee491bb..92d799a 100644 (file)
@@ -719,9 +719,9 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
                }
 
                gfs2_free_clones(rgd);
+               return_all_reservations(rgd);
                kfree(rgd->rd_bits);
                rgd->rd_bits = NULL;
-               return_all_reservations(rgd);
                kmem_cache_free(gfs2_rgrpd_cachep, rgd);
        }
 }
@@ -1370,6 +1370,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
+       if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
+               return -EROFS;
+
        if (!blk_queue_discard(q))
                return -EOPNOTSUPP;
 
index b285192..b3d951a 100644 (file)
@@ -738,6 +738,7 @@ restart:
        gfs2_jindex_free(sdp);
        /*  Take apart glock structures and buffer lists  */
        gfs2_gl_hash_clear(sdp);
+       truncate_inode_pages_final(&sdp->sd_aspace);
        gfs2_delete_debugfs_file(sdp);
        /*  Unmount the locking protocol  */
        gfs2_lm_unmount(sdp);