Skip to contentSkip to conversation

Turn do_sync_file_range() into do_sync_mapping_range()

PATCH In review Mark Fasheh 3 participants 4 messages Mar 20, 2007 – Mar 21, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Turn do_sync_file_range() into do_sync_mapping_range()

do_sync_file_range() accepts a file * from which it takes an address_space to sync. Abstract out the bulk of the function into do_sync_mapping_range() which takes the address_space directly. This way callers who want to sync an address_space directly can take advantage of the functionality provided.

do_sync_file_range() is preserved as a 3 line wrapper around do_sync_mapping_range().

Ocfs2 in particular would like to use this to initiate a sync of a specific inode range during truncate, where a file * may not be available.

---
 fs/sync.c          |   16 ++++------------
 include/linux/fs.h |   11 +++++++++--
 2 files changed, 13 insertions(+), 14 deletions(-)
fs/sync.c +4 -12
index d0feff6..b0675ec 100644
@@ -239,19 +239,11 @@ out:
 /*
  * `endbyte' is inclusive
  */
-int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
-			unsigned int flags)
+int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			  loff_t endbyte, unsigned int flags)
 {
-	int ret;
-	struct address_space *mapping;
-
-	mapping = file->f_mapping;
-	if (!mapping) {
-		ret = -EINVAL;
-		goto out;
-	}
+	int ret = 0;
 
-	ret = 0;
 	if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
 		ret = wait_on_page_writeback_range(mapping,
 					offset >> PAGE_CACHE_SHIFT,
@@ -275,4 +267,4 @@ int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
 out:
 	return ret;
 }
-EXPORT_SYMBOL_GPL(do_sync_file_range);
+EXPORT_SYMBOL_GPL(do_sync_mapping_range);
include/linux/fs.h +9 -2
index 1410e53..7fa4473 100644
@@ -842,8 +842,15 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
 extern int fcntl_getlease(struct file *filp);
 
 /* fs/sync.c */
-extern int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte,
-			unsigned int flags);
+extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
+			loff_t endbyte, unsigned int flags);
+static inline int do_sync_file_range(struct file *file, loff_t offset,
+				     loff_t endbyte, unsigned int flags)
+{
+	if (file->f_mapping == NULL)
+		return -EINVAL;
+	return do_sync_mapping_range(file->f_mapping, offset, endbyte, flags);
+}
 
 /* fs/locks.c */
 extern void locks_init_lock(struct file_lock *);
Signature · 1 line
1.4.4.2
#1 lore raw
Quoted 10 lines · On Tue, 20 Mar 2007 14:46:26 -0700 Mark Fasheh <[email protected]> wrote:

do_sync_file_range() accepts a file * from which it takes an address_space to sync. Abstract out the bulk of the function into do_sync_mapping_range() which takes the address_space directly. This way callers who want to sync an address_space directly can take advantage of the functionality provided.

do_sync_file_range() is preserved as a 3 line wrapper around do_sync_mapping_range().

Ocfs2 in particular would like to use this to initiate a sync of a specific inode range during truncate, where a file * may not be available.

I think we can remove do_sync_file_range() altogether?

#2 lore raw
In reply to Mark Fasheh
Quoted 10 lines · Mark Fasheh

do_sync_file_range() accepts a file * from which it takes an address_space to sync. Abstract out the bulk of the function into do_sync_mapping_range() which takes the address_space directly. This way callers who want to sync an address_space directly can take advantage of the functionality provided.

do_sync_file_range() is preserved as a 3 line wrapper around do_sync_mapping_range().

Ocfs2 in particular would like to use this to initiate a sync of a specific inode range during truncate, where a file * may not be available.

Looks good to me, but I agree with Andrew that we should simply kill do_sync_file_range, espcially as at least one of the callers has file->f_mapping guaranteed != NULL;

#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Mark Fasheh

do_sync_file_range() accepts a file * from which it takes an address_space to sync. Abstract out the bulk of the function into do_sync_mapping_range() which takes the address_space directly. This way callers who want to sync an address_space directly can take advantage of the functionality provided.

do_sync_file_range() is preserved as a 3 line wrapper around do_sync_mapping_range().

Quoted 6 lines
Quoted 2 lines

Ocfs2 in particular would like to use this to initiate a sync of a specific inode range during truncate, where a file * may not be available.

Looks good to me, but I agree with Andrew that we should simply kill do_sync_file_range, espcially as at least one of the callers has file->f_mapping guaranteed != NULL;

Ok - I'll post an updated patch series today. Thank you all for taking the time to look at this.

	--Mark

--
Mark Fasheh
Senior Software Developer, Oracle
[email protected]