]> Git Repo - J-linux.git/commitdiff
Merge tag 'iomap-5.10-merge-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
authorLinus Torvalds <[email protected]>
Wed, 14 Oct 2020 19:23:00 +0000 (12:23 -0700)
committerLinus Torvalds <[email protected]>
Wed, 14 Oct 2020 19:23:00 +0000 (12:23 -0700)
Pull iomap updates from Darrick Wong:
 "There's not a lot of new stuff going on here -- a little bit of code
  refactoring to make iomap workable with btrfs' fsync locking model,
  cleanups in preparation for adding THP support for filesystems, and
  fixing a data corruption issue for blocksize < pagesize filesystems.

  Summary:

   - Don't WARN_ON weird states that unprivileged users can create.

   - Don't invalidate page cache when direct writes want to fall back to
     buffered.

   - Fix some problems when readahead ios fail.

   - Fix a problem where inline data pages weren't getting flushed
     during an unshare operation.

   - Rework iomap to support arbitrarily many blocks per page in
     preparation to support THP for the page cache.

   - Fix a bug in the blocksize < pagesize buffered io path where we
     could fail to initialize the many-blocks-per-page uptodate bitmap
     correctly when the backing page is actually up to date. This could
     cause us to forget to write out dirty pages.

   - Split out the generic_write_sync at the end of the directio write
     path so that btrfs can drop the inode lock before sync'ing the
     file.

   - Call inode_dio_end before trying to sync the file after a O_DSYNC
     direct write (instead of afterwards) to match the behavior of the
     old directio code"

* tag 'iomap-5.10-merge-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  iomap: Call inode_dio_end() before generic_write_sync()
  iomap: Allow filesystem to call iomap_dio_complete without i_rwsem
  iomap: Set all uptodate bits for an Uptodate page
  iomap: Change calling convention for zeroing
  iomap: Convert iomap_write_end types
  iomap: Convert write_count to write_bytes_pending
  iomap: Convert read_count to read_bytes_pending
  iomap: Support arbitrarily many blocks per page
  iomap: Use bitmap ops to set uptodate bits
  iomap: Use kzalloc to allocate iomap_page
  fs: Introduce i_blocks_per_page
  iomap: Fix misplaced page flushing
  iomap: Use round_down/round_up macros in __iomap_write_begin
  iomap: Mark read blocks uptodate in write_begin
  iomap: Clear page error before beginning a write
  iomap: Fix direct I/O write consistency check
  iomap: fix WARN_ON_ONCE() from unprivileged users

1  2 
include/linux/dax.h
include/linux/pagemap.h

diff --combined include/linux/dax.h
index 4ec0bbf86205aded3dc6df560b4567c215a41793,951a851a04810b2ff2fce0fed2d039dfac05c238..e15357223565cf681d26d2fbef0bcbe5764bce8a
@@@ -58,8 -58,6 +58,8 @@@ static inline void set_dax_synchronous(
  {
        __set_dax_synchronous(dax_dev);
  }
 +bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
 +              int blocksize, sector_t start, sector_t len);
  /*
   * Check if given mapping is supported by the file / underlying device.
   */
@@@ -106,12 -104,6 +106,12 @@@ static inline bool dax_synchronous(stru
  static inline void set_dax_synchronous(struct dax_device *dax_dev)
  {
  }
 +static inline bool dax_supported(struct dax_device *dax_dev,
 +              struct block_device *bdev, int blocksize, sector_t start,
 +              sector_t len)
 +{
 +      return false;
 +}
  static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
                                struct dax_device *dax_dev)
  {
@@@ -197,23 -189,14 +197,23 @@@ static inline void dax_unlock_page(stru
  }
  #endif
  
 +#if IS_ENABLED(CONFIG_DAX)
  int dax_read_lock(void);
  void dax_read_unlock(int id);
 +#else
 +static inline int dax_read_lock(void)
 +{
 +      return 0;
 +}
 +
 +static inline void dax_read_unlock(int id)
 +{
 +}
 +#endif /* CONFIG_DAX */
  bool dax_alive(struct dax_device *dax_dev);
  void *dax_get_private(struct dax_device *dax_dev);
  long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages,
                void **kaddr, pfn_t *pfn);
 -bool dax_supported(struct dax_device *dax_dev, struct block_device *bdev,
 -              int blocksize, sector_t start, sector_t len);
  size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
                size_t bytes, struct iov_iter *i);
  size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr,
@@@ -231,19 -214,10 +231,18 @@@ vm_fault_t dax_finish_sync_fault(struc
  int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index);
  int dax_invalidate_mapping_entry_sync(struct address_space *mapping,
                                      pgoff_t index);
- int dax_iomap_zero(loff_t pos, unsigned offset, unsigned size,
-                       struct iomap *iomap);
+ s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap);
  static inline bool dax_mapping(struct address_space *mapping)
  {
        return mapping->host && IS_DAX(mapping->host);
  }
  
 +#ifdef CONFIG_DEV_DAX_HMEM_DEVICES
 +void hmem_register_device(int target_nid, struct resource *r);
 +#else
 +static inline void hmem_register_device(int target_nid, struct resource *r)
 +{
 +}
 +#endif
 +
  #endif
diff --combined include/linux/pagemap.h
index 1a3554f5d99295c5f5043203916f59a0c5d30437,85373328613820ab19bc0e2a8661b406c6cdd010..c3afd3242b54b6490f2ffebfd5b4d73973f797c6
@@@ -54,8 -54,7 +54,8 @@@ static inline void mapping_set_error(st
        __filemap_set_wb_err(mapping, error);
  
        /* Record it in superblock */
 -      errseq_set(&mapping->host->i_sb->s_wb_err, error);
 +      if (mapping->host)
 +              errseq_set(&mapping->host->i_sb->s_wb_err, error);
  
        /* Record it in flags for now, for legacy callers */
        if (error == -ENOSPC)
@@@ -279,7 -278,6 +279,7 @@@ pgoff_t page_cache_prev_miss(struct add
  #define FGP_NOFS              0x00000010
  #define FGP_NOWAIT            0x00000020
  #define FGP_FOR_MMAP          0x00000040
 +#define FGP_HEAD              0x00000080
  
  struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
                int fgp_flags, gfp_t cache_gfp_mask);
@@@ -311,37 -309,18 +311,37 @@@ static inline struct page *find_get_pag
   * @mapping: the address_space to search
   * @offset: the page index
   *
 - * Looks up the page cache slot at @mapping & @offset.  If there is a
 + * Looks up the page cache entry at @mapping & @offset.  If there is a
   * page cache page, it is returned locked and with an increased
   * refcount.
   *
 - * Otherwise, %NULL is returned.
 - *
 - * find_lock_page() may sleep.
 + * Context: May sleep.
 + * Return: A struct page or %NULL if there is no page in the cache for this
 + * index.
   */
  static inline struct page *find_lock_page(struct address_space *mapping,
 -                                      pgoff_t offset)
 +                                      pgoff_t index)
 +{
 +      return pagecache_get_page(mapping, index, FGP_LOCK, 0);
 +}
 +
 +/**
 + * find_lock_head - Locate, pin and lock a pagecache page.
 + * @mapping: The address_space to search.
 + * @offset: The page index.
 + *
 + * Looks up the page cache entry at @mapping & @offset.  If there is a
 + * page cache page, its head page is returned locked and with an increased
 + * refcount.
 + *
 + * Context: May sleep.
 + * Return: A struct page which is !PageTail, or %NULL if there is no page
 + * in the cache for this index.
 + */
 +static inline struct page *find_lock_head(struct address_space *mapping,
 +                                      pgoff_t index)
  {
 -      return pagecache_get_page(mapping, offset, FGP_LOCK, 0);
 +      return pagecache_get_page(mapping, index, FGP_LOCK | FGP_HEAD, 0);
  }
  
  /**
@@@ -392,15 -371,6 +392,15 @@@ static inline struct page *grab_cache_p
                        mapping_gfp_mask(mapping));
  }
  
 +/* Does this page contain this index? */
 +static inline bool thp_contains(struct page *head, pgoff_t index)
 +{
 +      /* HugeTLBfs indexes the page cache in units of hpage_size */
 +      if (PageHuge(head))
 +              return head->index == index;
 +      return page_index(head) == (index & ~(thp_nr_pages(head) - 1UL));
 +}
 +
  /*
   * Given the page we found in the page cache, return the page corresponding
   * to this index in the file
@@@ -414,6 -384,8 +414,6 @@@ static inline struct page *find_subpage
        return head + (index & (thp_nr_pages(head) - 1));
  }
  
 -struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
 -struct page *find_lock_entry(struct address_space *mapping, pgoff_t offset);
  unsigned find_get_entries(struct address_space *mapping, pgoff_t start,
                          unsigned int nr_entries, struct page **entries,
                          pgoff_t *indices);
@@@ -927,4 -899,20 +927,20 @@@ static inline int page_mkwrite_check_tr
        return offset;
  }
  
+ /**
+  * i_blocks_per_page - How many blocks fit in this page.
+  * @inode: The inode which contains the blocks.
+  * @page: The page (head page if the page is a THP).
+  *
+  * If the block size is larger than the size of this page, return zero.
+  *
+  * Context: The caller should hold a refcount on the page to prevent it
+  * from being split.
+  * Return: The number of filesystem blocks covered by this page.
+  */
+ static inline
+ unsigned int i_blocks_per_page(struct inode *inode, struct page *page)
+ {
+       return thp_size(page) >> inode->i_blkbits;
+ }
  #endif /* _LINUX_PAGEMAP_H */
This page took 0.065536 seconds and 4 git commands to generate.