Skip to contentSkip to conversation

migrate ocfs2 DIO from buffer_head to iomap

RFC PATCH New Heming Zhao 1 participant 4 messages Nov 24 OCFS2

lore
Share & tools
lore

Heming Zhao

author reviewer
#0 lore raw

v10 cover migrate ocfs2 DIO from buffer_head to iomap

This patch set migrates ocfs2 Direct I/O (DIO) from buffer_head mode to iomap mode. It is based on commit aebb72744764 (v7.4-rc3), and also incorporates Joseph's code and ideas from [1]:

V10 changelog:

patch 1/3: fix a typo (gridge => bridge)
patch 2/3: fix commit log two mistakes found by Joseph.
patch 3/3:
- based on Joseph's review comments
- ocfs2_dio_wr_map_blocks(): move the condition check IOMAP_NOWAIT before checking fast path.
- based on sashiko's review comments
- remove comparing line in ocfs2_dio_clear_orphan_locked()
- add re-accessing i_size code in ocfs2_file_write_iter()
- add a comments for del_orphan inode pending issue in ocfs2_file_write_iter()
- reject unaligned I/O even when DIO falls back to buffered I/O

--------------

# test report

This patch set has been tested on 7.4-rc3 kernel

## ltp

runltp -f dio -d /mnt/ocfs2/

results: passed

## xfstests

./check -g quick -T -b -s ocfs2 -e generic/081 \
-e generic/266 -e generic/272 -e generic/281 \
-e generic/338 -e generic/347 -e generic/361 \
-e generic/628 -e generic/629 -e generic/648 -e generic/650

OCFS2_MKFS_LOCAL_OPT="-b 2K -C 4K --fs-features=local --fs-feature-level=max-features"
Failures: generic/003 generic/056 generic/091 generic/094 generic/177 generic/211 generic/225 generic/263 generic/321 generic/322 generic/329 generic/331 generic/370 generic/376 generic/424 generic/448 generic/467 generic/477 generic/481 generic/498 generic/510 generic/512 generic/513 generic/534 generic/537 generic/552 generic/557 generic/563 generic/578 generic/588 generic/607 generic/620 generic/630 generic/755 generic/760 generic/771 generic/777 generic/779 generic/784
Failed 39 of 632 tests

OCFS2_MKFS_LOCAL_OPT="-b 4K -C 4K --fs-features=local --fs-feature-level=max-features"
Failures: generic/003 generic/056 generic/070 generic/091 generic/094 generic/177 generic/211 generic/225 generic/263 generic/321 generic/322 generic/329 generic/331 generic/370 generic/376 generic/424 generic/448 generic/467 generic/477 generic/481 generic/498 generic/510 generic/512 generic/513 generic/534 generic/537 generic/552 generic/557 generic/563 generic/578 generic/588 generic/607 generic/620 generic/630 generic/755 generic/760 generic/771 generic/777 generic/779 generic/784
Failed 40 of 632 tests

OCFS2_MKFS_LOCAL_OPT="-b 2K -C 8K --fs-features=local --fs-feature-level=max-features"
Failures: generic/003 generic/056 generic/075 generic/091 generic/094 generic/112 generic/177 generic/211 generic/225 generic/263 generic/321 generic/322 generic/329 generic/331 generic/370 generic/376 generic/424 generic/448 generic/467 generic/477 generic/481 generic/498 generic/510 generic/512 generic/513 generic/534 generic/537 generic/552 generic/557 generic/563 generic/564 generic/578 generic/588 generic/607 generic/620 generic/630 generic/755 generic/759 generic/760 generic/771 generic/777 generic/779 generic/784 ocfs2/001
Failed 44 of 632 tests

## fio

no test

------
[1]:
https://gitee.com/anolis/storage-cloud-kernel/commit/ea3fe75e2060118ba093e90b1cd34fa382914b29

[2]:
https://sashiko.dev/#/patchset/20261103135605.22943-1-heming.zhao%40suse.com

[3]:
v1 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v2 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v3 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v3 sashiko review:
https://sashiko.dev/#/patchset/20261018143319.22329-1-heming.zhao%40suse.com
v4 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v4 sashiko review:
https://sashiko.dev/#/patchset/20261103135605.22943-1-heming.zhao%40suse.com
v5 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v5 sashiko review:
https://sashiko.dev/#/patchset/20261105071930.16399-1-heming.zhao%40suse.com
v6 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v6 sashiko review:
https://sashiko.dev/#/patchset/20261115154013.9379-1-heming.zhao%40suse.com
v7 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v7 sashiko review:
- https://sashiko.dev/#/patchset/20261117150053.18417-1-heming.zhao%40suse.com
- https://sashiko.dev/#/patchset/20261118002050.9019-1-heming.zhao%40suse.com
v8 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v8 sashiko review:
https://sashiko.dev/#/patchset/20261119064029.11910-1-heming.zhao%40suse.com
v9 patch set:
https://lore.kernel.org/ocfs2-devel/[email protected]/
v9 sashiko review:
https://sashiko.dev/#/patchset/20261120060014.12087-1-heming.zhao%40suse.com

-----------------------

Heming Zhao (3):
ocfs2: Add new ocfs2_map_blocks() to introduce iomap feature
ocfs2: switch DIO read path from buffer_head to iomap
ocfs2: switch dio write path from buffer_head to iomap

 fs/ocfs2/Kconfig      |    2 +-
 fs/ocfs2/aops.c       | 1689 ++++++++++++++++++++++++++++++++---------
 fs/ocfs2/aops.h       |   43 +-
 fs/ocfs2/extent_map.c |   34 +-
 fs/ocfs2/extent_map.h |    3 +
 fs/ocfs2/file.c       |  342 ++++++++-
 fs/ocfs2/inode.h      |    9 +
 fs/ocfs2/mmap.c       |    2 +-
 fs/ocfs2/ocfs2.h      |   25 +-
 fs/ocfs2/super.c      |    3 +
 10 files changed, 1722 insertions(+), 430 deletions(-)
Signature · 1 line
2.55.0
author reviewer
#1 lore raw

RFC PATCH v10 1/3 ocfs2: Add new ocfs2_map_blocks() to introduce iomap feature

As part of migrating OCFS2 DIO read/write code paths towards the modern and performant iomap framework, here introduces ocfs2_map_blocks() to replace the legacy, high-overhead buffer_head based block mapping routines.

In addition, OCFS2_MAP_* flags are defined to bridge OCFS2 internal block mapping flags with the iomap API requirements.

Subsequent iomap integration patches will build on this core block mapping routine. The implementation draws inspiration from ext4_map_blocks().

---
 fs/ocfs2/aops.c  | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ocfs2/aops.h  |  2 ++
 fs/ocfs2/ocfs2.h | 25 ++++++++++++++++-
 3 files changed, 96 insertions(+), 1 deletion(-)
fs/ocfs2/aops.c +70 -0
index 4acdbb70882c..64fcf6eb3d89 100644
@@ -126,6 +126,76 @@ static int ocfs2_lock_get_block(struct inode *inode, sector_t iblock,
 	return ret;
 }
 
+/* ocfs2 never allocates in this function */
+int ocfs2_map_blocks(struct inode *inode, struct ocfs2_map_block *map,
+		    int flags)
+{
+	int err = 0;
+	unsigned int ext_flags;
+	u64 max_blocks = map->len;
+	u64 p_blkno, count, past_eof;
+	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	int create = flags & OCFS2_GET_BLOCKS_CREATE;
+
+	if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE)
+		mlog(ML_NOTICE, "map_block on system inode 0x%p (%llu)\n",
+		     inode, inode->i_ino);
+
+	err = ocfs2_extent_map_get_blocks(inode, map->lblk, &p_blkno, &count,
+					  &ext_flags);
+	if (err) {
+		mlog(ML_ERROR, "get_blocks() failed, inode: 0x%p, "
+		     "block: %llu\n", inode, map->lblk);
+		goto bail;
+	}
+
+	if (max_blocks < count)
+		count = max_blocks;
+
+	map->pblk = p_blkno;
+	map->len = count;
+
+	/*
+	 * If we see this on a sparse file system, then a truncate has
+	 * raced us and removed the cluster. We treat this as a hole
+	 * and skip setting the iomap flags. The caller will set
+	 * iomap->type to IOMAP_HOLE.
+	 */
+	if (create && map->pblk == 0 && ocfs2_sparse_alloc(osb))
+		goto bail;
+
+	if (p_blkno) {
+		if (ext_flags & OCFS2_EXT_UNWRITTEN)
+			map->flags |= OCFS2_MAP_UNWRITTEN;
+		else
+			map->flags |= OCFS2_MAP_MAPPED;
+	}
+
+	if (!ocfs2_sparse_alloc(osb)) {
+		if (map->pblk == 0) {
+			err = -EIO;
+			mlog(ML_ERROR,
+			     "iblock = %llu p_blkno = %llu blkno=(%llu)\n",
+			     (unsigned long long)map->lblk,
+			     (unsigned long long)map->pblk,
+			     (unsigned long long)OCFS2_I(inode)->ip_blkno);
+			mlog(ML_ERROR, "Size %llu, clusters %u\n",
+			     (unsigned long long)i_size_read(inode),
+			     OCFS2_I(inode)->ip_clusters);
+			dump_stack();
+			goto bail;
+		}
+	}
+
+	past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
+
+	if (create && (map->lblk >= past_eof))
+		map->flags |= OCFS2_MAP_NEW;
+
+bail:
+	return err;
+}
+
 int ocfs2_get_block(struct inode *inode, sector_t iblock,
 		    struct buffer_head *bh_result, int create)
 {
fs/ocfs2/aops.h +2 -0
index 114efc9111e4..8dd6edd7c1a1 100644
@@ -42,6 +42,8 @@ int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size);
 
 int ocfs2_get_block(struct inode *inode, sector_t iblock,
 		    struct buffer_head *bh_result, int create);
+int ocfs2_map_blocks(struct inode *inode, struct ocfs2_map_block *map,
+		    int flags);
 /* all ocfs2_dio_end_io()'s fault */
 #define ocfs2_iocb_is_rw_locked(iocb) \
 	test_bit(0, (unsigned long *)&iocb->private)
fs/ocfs2/ocfs2.h +24 -1
index e3bb3cc0b25a..b4583b3170e2 100644
@@ -514,7 +514,30 @@ struct ocfs2_super
 	struct ocfs2_filecheck_sysfs_entry osb_fc_ent;
 };
 
-#define OCFS2_SB(sb)	    ((struct ocfs2_super *)(sb)->s_fs_info)
+/*
+ * Logical to physical block mapping, used by ocfs2_map_blocks()
+ *
+ * This structure is used to pass requests into ocfs2_map_blocks()
+ * as well as to store the information returned by ocfs2_map_blocks().
+ * It takes less room on the stack than a struct buffer_head.
+ */
+#define OCFS2_MAP_NEW			BIT(BH_New)
+#define OCFS2_MAP_MAPPED		BIT(BH_Mapped)
+#define OCFS2_MAP_UNWRITTEN		BIT(BH_Unwritten)
+#define OCFS2_MAP_FLAGS		(OCFS2_MAP_NEW | OCFS2_MAP_MAPPED |\
+				 OCFS2_MAP_UNWRITTEN)
+
+struct ocfs2_map_block {
+	u64 pblk; /* physical block# */
+	u64 lblk; /* logical block# */
+	u64 len;  /* number of block */
+	unsigned int flags;
+};
+
+/* Flags used by ocfs2_map_blocks() */
+#define OCFS2_GET_BLOCKS_CREATE	(0x0001)
+
+#define OCFS2_SB(sb)	((struct ocfs2_super *)(sb)->s_fs_info)
 
 /* Useful typedef for passing around journal access functions */
 typedef int (*ocfs2_journal_access_func)(handle_t *handle,
Signature · 1 line
2.55.0
author reviewer
#2 lore raw

RFC PATCH v10 2/3 ocfs2: switch DIO read path from buffer_head to iomap

In reply to Heming Zhao

Migrates the DIO read path from the legacy buffer_head infrastructure to the modern and more efficient iomap framework.

Under the current code, ocfs2 holds a cluster lock during DIO via ocfs2_iocb_set_rw_locked(), and releases the cluster lock in ocfs2_dio_end_io() via ocfs2_iocb_clear_rw_locked(). The lock level is stashed in iocb->private.

However, iomap DIO owns that field (it stores a bio there for polled I/O and unconditionally clears it before calling ->end_io). Any side-channel state packed into iocb->private is corrupted, which trips the end_io lock-state check.

Instead, encode the unlock level by passing distinct iomap_dio_ops methods e.g.: ocfs2_iomap_dio_ops_r_pr ocfs2_iomap_dio_ops_w_pr for PRMODE or ocfs2_iomap_dio_ops_w_ex for EXMODE. Also note that the ops_w_{pr|ex} are defined in the next patch.

Additionally, the *_iter() functions use the split __iomap_dio_rw() + iomap_dio_complete() API so they can determine unambiguously, from the return value, whether the completion handler already dropped the lock (real I/O, sync or -EIOCBQUEUED) or whether the caller must drop it (no I/O issued, or buffered fallback).

The new function ocfs2_iomap_begin() performs a similar role to ocfs2_get_block(). While ocfs2_get_block() retrieves only one block per call, ocfs2_iomap_begin() can handle multiple blocks at once.

---
 fs/ocfs2/Kconfig |   1 +
 fs/ocfs2/aops.c  | 107 +++++++++++++++++++++++++++++++++++++++++++++--
 fs/ocfs2/aops.h  |   5 +++
 fs/ocfs2/file.c  |  60 ++++++++++++++++++++++----
 4 files changed, 161 insertions(+), 12 deletions(-)
fs/ocfs2/Kconfig +1 -0
index 2514d36cbe01..bf1678a5eb01 100644
@@ -7,6 +7,7 @@ config OCFS2_FS
 	select CRC32
 	select QUOTA
 	select QUOTA_TREE
+	select FS_IOMAP
 	select FS_POSIX_ACL
 	select LEGACY_DIRECT_IO
 	help
fs/ocfs2/aops.c +104 -3

138 lines not on this page · raw message

fs/ocfs2/aops.h +5 -0
index 8dd6edd7c1a1..72de1e764a57 100644
@@ -7,6 +7,11 @@
 #define OCFS2_AOPS_H
 
 #include <linux/fs.h>
+#include <linux/iomap.h>
+
+extern const struct iomap_dio_ops ocfs2_iomap_dio_ops_r_pr;
+int ocfs2_iomap_next(const struct iomap_iter *iter, struct iomap *iomap,
+			    struct iomap *srcmap);
 
 int ocfs2_map_folio_blocks(struct folio *folio, u64 *p_blkno,
 			  struct inode *inode, unsigned int from,
fs/ocfs2/file.c +51 -9

95 lines not on this page · raw message

Signature · 1 line
2.55.0
author reviewer
#3 lore raw

RFC PATCH v10 3/3 ocfs2: switch dio write path from buffer_head to iomap

In reply to Heming Zhao

Converts OCFS2's DIO write path from the legacy buffer_head infrastructure to the modern iomap framework.

The buffer_head based ocfs2_dio_wr_get_block() is replaced by ocfs2_dio_wr_map_blocks(). Instead of one cluster per call, it now hands iomap a mapping of as many clusters as can be described by a single struct iomap: up to 16MB, stopped at the first cluster that is not of the same kind as the first one (hole, unwritten, written).

Implement ocfs2_dio_end_io() and ocfs2_dio_end_io_write() to handle IO completion. They convert UNWRITTEN extents, updates inode size (EOF).

In the buffer_head path, ocfs2_dio_wr_get_block() stores dwc in bh->b_private, enabling it to detect the first call for an IO chunk and invoke ocfs2_add_inode_to_orphan() to protect the extent allocation. However, iomap doesn't provide a similar private field. Therefore, moves ocfs2_add_inode_to_orphan() from ocfs2_dio_wr_map_blocks(the buffer_head counterpart to ocfs2_dio_wr_get_block()) to ocfs2_file_write_iter().

It is also impossible t pass The dwc to iomap_dio_ops.end_io, the iomap ->end_io callback cannot effectively distinguish between I/Os initiated by different threads concurrently. For example, when multiple DIO write threads operate on the same inode concurrently, the end_io callback without the dwc context may incorrectly delete an orphan inode created by another thread, leading to a crash. The fix is to move the orphan inode deletion from end_io into ocfs2_file_write_iter(). In ocfs2_file_write_iter(), inode_lock() serializes the write threads, and IOMAP_DIO_FORCE_WAIT ensures that the function only returns after the bio completes. This guarantees that i_size has already been updated when ocfs2_dio_del_orphan() is called.

iomap calls ->iomap_begin() once per mapping but ->end_io() once per io, and the latter only gets the kiocb, so the kiocb is used as the identity of the io: ocfs2_file_write_iter() passes it in iomap_iter.private, ocfs2_iomap_next() forwards it to ocfs2_dio_wr_map_blocks(), and each unwritten record stores it in ue_owner with the cluster range it covers.

Doesn't like ocfs2_dio_wr_get_block(), move the zero operations from ocfs2_dio_wr_map_blocks() to ocfs2_file_write_iter(). If do the zeroing in ocfs2_dio_wr_map_blocks() would zero blocks that earlier mappings of this same dio have already written, as i_size is only updated at dio completion. this will makes xfstests generic/538 failure.

---
 fs/ocfs2/Kconfig      |    1 -
 fs/ocfs2/aops.c       | 1600 +++++++++++++++++++++++++++++++----------
 fs/ocfs2/aops.h       |   36 +-
 fs/ocfs2/extent_map.c |   34 +-
 fs/ocfs2/extent_map.h |    3 +
 fs/ocfs2/file.c       |  282 +++++++-
 fs/ocfs2/inode.h      |    9 +
 fs/ocfs2/mmap.c       |    2 +-
 fs/ocfs2/super.c      |    3 +
 9 files changed, 1509 insertions(+), 461 deletions(-)
fs/ocfs2/Kconfig +0 -1
index bf1678a5eb01..74bc2008ef0b 100644
@@ -9,7 +9,6 @@ config OCFS2_FS
 	select QUOTA_TREE
 	select FS_IOMAP
 	select FS_POSIX_ACL
-	select LEGACY_DIRECT_IO
 	help
 	  OCFS2 is a general purpose extent based shared disk cluster file
 	  system with many similarities to ext3. It supports 64 bit inode
fs/ocfs2/aops.c +1207 -393

1,993 lines not on this page · raw message

fs/ocfs2/aops.h +6 -30
index 72de1e764a57..2219aad12b84 100644
@@ -10,6 +10,8 @@
 #include <linux/iomap.h>
 
 extern const struct iomap_dio_ops ocfs2_iomap_dio_ops_r_pr;
+extern const struct iomap_dio_ops ocfs2_iomap_dio_ops_w_pr;
+extern const struct iomap_dio_ops ocfs2_iomap_dio_ops_w_ex;
 int ocfs2_iomap_next(const struct iomap_iter *iter, struct iomap *iomap,
 			    struct iomap *srcmap);
 
@@ -39,7 +41,8 @@ typedef enum {
 int ocfs2_write_begin_nolock(struct address_space *mapping,
 		loff_t pos, unsigned len, ocfs2_write_type_t type,
 		struct folio **foliop, void **fsdata,
-		struct buffer_head *di_bh, struct folio *mmap_folio);
+		struct buffer_head *di_bh, struct folio *mmap_folio,
+		void *owner);
 
 int ocfs2_read_inline_data(struct inode *inode, struct folio *folio,
 			   struct buffer_head *di_bh);
@@ -47,36 +50,9 @@ int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size);
 
 int ocfs2_get_block(struct inode *inode, sector_t iblock,
 		    struct buffer_head *bh_result, int create);
+int ocfs2_dio_zero_eof(struct inode *inode, loff_t pos, size_t count);
+void ocfs2_dio_clear_orphan(struct inode *inode);
 int ocfs2_map_blocks(struct inode *inode, struct ocfs2_map_block *map,
 		    int flags);
-/* all ocfs2_dio_end_io()'s fault */
-#define ocfs2_iocb_is_rw_locked(iocb) \
-	test_bit(0, (unsigned long *)&iocb->private)
-static inline void ocfs2_iocb_set_rw_locked(struct kiocb *iocb, int level)
-{
-	set_bit(0, (unsigned long *)&iocb->private);
-	if (level)
-		set_bit(1, (unsigned long *)&iocb->private);
-	else
-		clear_bit(1, (unsigned long *)&iocb->private);
-}
-
-/*
- * Using a named enum representing lock types in terms of #N bit stored in
- * iocb->private, which is going to be used for communication between
- * ocfs2_dio_end_io() and ocfs2_file_write/read_iter().
- */
-enum ocfs2_iocb_lock_bits {
-	OCFS2_IOCB_RW_LOCK = 0,
-	OCFS2_IOCB_RW_LOCK_LEVEL,
-	OCFS2_IOCB_NUM_LOCKS
-};
-
-#define ocfs2_iocb_init_rw_locked(iocb) \
-	(iocb->private = NULL)
-#define ocfs2_iocb_clear_rw_locked(iocb) \
-	clear_bit(OCFS2_IOCB_RW_LOCK, (unsigned long *)&iocb->private)
-#define ocfs2_iocb_rw_locked_level(iocb) \
-	test_bit(OCFS2_IOCB_RW_LOCK_LEVEL, (unsigned long *)&iocb->private)
 
 #endif /* OCFS2_FILE_H */
fs/ocfs2/extent_map.c +26 -8
index eb5dcd17d437..2510e68fbde8 100644
@@ -602,9 +602,9 @@ int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
 	return ret;
 }
 
-int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
-		       u32 *p_cluster, u32 *num_clusters,
-		       unsigned int *extent_flags)
+static int __ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
+				u32 *p_cluster, u32 *num_clusters,
+				unsigned int *extent_flags, bool cache)
 {
 	int ret;
 	unsigned int hole_len, flags = 0;
@@ -617,10 +617,12 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
 		goto out;
 	}
 
-	ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster,
-				      num_clusters, extent_flags);
-	if (ret == 0)
-		goto out;
+	if (cache) {
+		ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster,
+					      num_clusters, extent_flags);
+		if (ret == 0)
+			goto out;
+	}
 
 	ret = ocfs2_read_inode_block(inode, &di_bh);
 	if (ret) {
@@ -650,7 +652,8 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
 					      p_cluster, num_clusters);
 		flags = rec.e_flags;
 
-		ocfs2_extent_map_insert_rec(inode, &rec);
+		if (cache)
+			ocfs2_extent_map_insert_rec(inode, &rec);
 	}
 
 	if (extent_flags)
@@ -661,6 +664,21 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
 	return ret;
 }
 
+int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster,
+		       u32 *num_clusters, unsigned int *extent_flags)
+{
+	return __ocfs2_get_clusters(inode, v_cluster, p_cluster, num_clusters,
+				    extent_flags, true);
+}
+
+int ocfs2_get_clusters_uncached(struct inode *inode, u32 v_cluster,
+				u32 *p_cluster, u32 *num_clusters,
+				unsigned int *extent_flags)
+{
+	return __ocfs2_get_clusters(inode, v_cluster, p_cluster, num_clusters,
+				    extent_flags, false);
+}
+
 /*
  * This expects alloc_sem to be held. The allocation cannot change at
  * all while the map is in the process of being updated.
fs/ocfs2/extent_map.h +3 -0
index bc4ed59fb925..b5b2d511ef9d 100644
@@ -32,6 +32,9 @@ void ocfs2_extent_map_insert_rec(struct inode *inode,
 
 int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster,
 		       u32 *num_clusters, unsigned int *extent_flags);
+int ocfs2_get_clusters_uncached(struct inode *inode, u32 v_cluster,
+				u32 *p_cluster, u32 *num_clusters,
+				unsigned int *extent_flags);
 int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno,
 				u64 *ret_count, unsigned int *extent_flags);
 
fs/ocfs2/file.c +254 -28

358 lines not on this page · raw message

fs/ocfs2/inode.h +9 -0
index 07bd838e7843..68f40668740d 100644
@@ -40,6 +40,15 @@ struct ocfs2_inode_info
 
 	/* Record unwritten extents during direct io. */
 	struct list_head		ip_unwritten_list;
+	/*
+	 * Woken when entries leave ip_unwritten_list. A direct write waits
+	 * on it for the entries of the other dios, see
+	 * ocfs2_dio_wr_map_blocks().
+	 */
+	wait_queue_head_t		ip_unwritten_wq;
+
+	pid_t				ip_dio_orphan_pid;
+	loff_t				ip_dio_orphan_end;
 
 	/* protected by recovery_lock. */
 	struct inode			*ip_next_orphan;
fs/ocfs2/mmap.c +1 -1
index 6c570157caf1..885583302c0d 100644
@@ -90,7 +90,7 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
 		len = ((size - 1) & ~PAGE_MASK) + 1;
 
 	err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP,
-				       &locked_folio, &fsdata, di_bh, folio);
+				       &locked_folio, &fsdata, di_bh, folio, NULL);
 	if (err) {
 		if (err != -ENOSPC)
 			mlog_errno(err);
fs/ocfs2/super.c +3 -0
index 0781c5cbdb11..188cd2535625 100644
@@ -1632,6 +1632,7 @@ static void ocfs2_inode_init_once(void *data)
 	ocfs2_extent_map_init(&oi->vfs_inode);
 	INIT_LIST_HEAD(&oi->ip_io_markers);
 	INIT_LIST_HEAD(&oi->ip_unwritten_list);
+	init_waitqueue_head(&oi->ip_unwritten_wq);
 	oi->ip_dir_start_lookup = 0;
 	init_rwsem(&oi->ip_alloc_sem);
 	init_rwsem(&oi->ip_xattr_sem);
@@ -1640,6 +1641,8 @@ static void ocfs2_inode_init_once(void *data)
 	oi->ip_blkno = 0ULL;
 	oi->ip_clusters = 0;
 	oi->ip_next_orphan = NULL;
+	oi->ip_dio_orphan_pid = 0;
+	oi->ip_dio_orphan_end = 0ULL;
 
 	ocfs2_resv_init_once(&oi->ip_la_data_resv);
 
Signature · 1 line
2.55.0