ntfs3.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] fs/ntfs3: Speed up hardlink creation
@ 2021-09-13 15:09 Konstantin Komarov
  2021-09-13 15:12 ` [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext Konstantin Komarov
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-13 15:09 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

xfstest generic/041 was taking some time before failing,
so this series aims to fix it and speed up.
Because of this we raise hardlinks limit to 4000.
There are no drawbacks or regressions.
Theoretically we can raise all the way up to ffff,
but there is no practical use for this.

Konstantin Komarov (3):
  fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext
  fs/ntfs3: Change max hardlinks limit to 4000
  fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update

 fs/ntfs3/attrib.c   | 2 +-
 fs/ntfs3/attrlist.c | 6 +++---
 fs/ntfs3/frecord.c  | 9 ++++++++-
 fs/ntfs3/fslog.c    | 8 ++++----
 fs/ntfs3/fsntfs.c   | 8 ++++----
 fs/ntfs3/inode.c    | 2 +-
 fs/ntfs3/ntfs.h     | 8 +++++---
 fs/ntfs3/ntfs_fs.h  | 4 ++--
 fs/ntfs3/xattr.c    | 2 +-
 9 files changed, 29 insertions(+), 20 deletions(-)

-- 
2.33.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext
  2021-09-13 15:09 [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Konstantin Komarov
@ 2021-09-13 15:12 ` Konstantin Komarov
  2021-09-18  7:02   ` Kari Argillander
  2021-09-13 15:14 ` [PATCH 2/3] fs/ntfs3: Change max hardlinks limit to 4000 Konstantin Komarov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-13 15:12 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

Do not try to insert attribute if there is no room in record.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/frecord.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 938b12d56ca6..834cb361f61f 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -956,6 +956,13 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
 			continue;
 		}
 
+		/*
+		 * Do not try to insert this attribute
+		 * if there is no room in record.
+		 */
+		if (le32_to_cpu(mi->mrec->used) + asize > sbi->record_size)
+			continue;
+
 		/* Try to insert attribute into this subrecord. */
 		attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
 				       name_off, svcn, ins_le);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] fs/ntfs3: Change max hardlinks limit to 4000
  2021-09-13 15:09 [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Konstantin Komarov
  2021-09-13 15:12 ` [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext Konstantin Komarov
@ 2021-09-13 15:14 ` Konstantin Komarov
  2021-09-13 15:15 ` [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update Konstantin Komarov
  2021-09-18  7:01 ` [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Kari Argillander
  3 siblings, 0 replies; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-13 15:14 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

xfstest generic/041 works with 3003, so we need to raise limit.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/ntfs.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h
index 6bb3e595263b..6c604204d77b 100644
--- a/fs/ntfs3/ntfs.h
+++ b/fs/ntfs3/ntfs.h
@@ -20,9 +20,11 @@
 
 #define NTFS_NAME_LEN 255
 
-/* ntfs.sys used 500 maximum links on-disk struct allows up to 0xffff. */
-#define NTFS_LINK_MAX 0x400
-//#define NTFS_LINK_MAX 0xffff
+/*
+ * ntfs.sys used 500 maximum links on-disk struct allows up to 0xffff.
+ * xfstest generic/041 creates 3003 hardlinks.
+ */
+#define NTFS_LINK_MAX 4000
 
 /*
  * Activate to use 64 bit clusters instead of 32 bits in ntfs.sys.
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update
  2021-09-13 15:09 [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Konstantin Komarov
  2021-09-13 15:12 ` [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext Konstantin Komarov
  2021-09-13 15:14 ` [PATCH 2/3] fs/ntfs3: Change max hardlinks limit to 4000 Konstantin Komarov
@ 2021-09-13 15:15 ` Konstantin Komarov
  2021-09-18  7:01 ` [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Kari Argillander
  3 siblings, 0 replies; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-13 15:15 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

This allows to wait only when it's requested.
It speeds up creation of hardlinks.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/attrib.c   | 2 +-
 fs/ntfs3/attrlist.c | 6 +++---
 fs/ntfs3/frecord.c  | 2 +-
 fs/ntfs3/fslog.c    | 8 ++++----
 fs/ntfs3/fsntfs.c   | 8 ++++----
 fs/ntfs3/inode.c    | 2 +-
 fs/ntfs3/ntfs_fs.h  | 4 ++--
 fs/ntfs3/xattr.c    | 2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index b1055b284c60..0ae51a360899 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -291,7 +291,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
 		if (!rsize) {
 			/* Empty resident -> Non empty nonresident. */
 		} else if (!is_data) {
-			err = ntfs_sb_write_run(sbi, run, 0, data, rsize);
+			err = ntfs_sb_write_run(sbi, run, 0, data, rsize, 0);
 			if (err)
 				goto out2;
 		} else if (!page) {
diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
index fa32399eb517..e41443cb3d63 100644
--- a/fs/ntfs3/attrlist.c
+++ b/fs/ntfs3/attrlist.c
@@ -336,7 +336,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
 
 	if (attr && attr->non_res) {
 		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-					al->size);
+					al->size, 0);
 		if (err)
 			return err;
 		al->dirty = false;
@@ -423,7 +423,7 @@ bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
 	return true;
 }
 
-int al_update(struct ntfs_inode *ni)
+int al_update(struct ntfs_inode *ni, int sync)
 {
 	int err;
 	struct ATTRIB *attr;
@@ -445,7 +445,7 @@ int al_update(struct ntfs_inode *ni)
 		memcpy(resident_data(attr), al->le, al->size);
 	} else {
 		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-					al->size);
+					al->size, sync);
 		if (err)
 			goto out;
 
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 834cb361f61f..5910f6c179b8 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3212,7 +3212,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 					goto out;
 			}
 
-			err = al_update(ni);
+			err = al_update(ni, sync);
 			if (err)
 				goto out;
 		}
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index b5853aed0e25..88c07da08fd5 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -2219,7 +2219,7 @@ static int last_log_lsn(struct ntfs_log *log)
 
 			err = ntfs_sb_write_run(log->ni->mi.sbi,
 						&log->ni->file.run, off, page,
-						log->page_size);
+						log->page_size, 0);
 
 			if (err)
 				goto out;
@@ -3710,7 +3710,7 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
 
 	if (a_dirty) {
 		attr = oa->attr;
-		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes);
+		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes, 0);
 		if (err)
 			goto out;
 	}
@@ -5152,10 +5152,10 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
 
 	ntfs_fix_pre_write(&rh->rhdr, log->page_size);
 
-	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size);
+	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size, 0);
 	if (!err)
 		err = ntfs_sb_write_run(sbi, &log->ni->file.run, log->page_size,
-					rh, log->page_size);
+					rh, log->page_size, 0);
 
 	kfree(rh);
 	if (err)
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index 91e3743e1442..c89a0f5c5ad4 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -1080,7 +1080,7 @@ int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 }
 
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-		      u64 vbo, const void *buf, size_t bytes)
+		      u64 vbo, const void *buf, size_t bytes, int sync)
 {
 	struct super_block *sb = sbi->sb;
 	u8 cluster_bits = sbi->cluster_bits;
@@ -1100,7 +1100,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
 
 	for (;;) {
 		u32 op = len < bytes ? len : bytes;
-		int err = ntfs_sb_write(sb, lbo, op, buf, 0);
+		int err = ntfs_sb_write(sb, lbo, op, buf, sync);
 
 		if (err)
 			return err;
@@ -2175,7 +2175,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
 	/* Write main SDS bucket. */
 	err = ntfs_sb_write_run(sbi, &ni->file.run, sbi->security.next_off,
-				d_security, aligned_sec_size);
+				d_security, aligned_sec_size, 0);
 
 	if (err)
 		goto out;
@@ -2193,7 +2193,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
 	/* Write copy SDS bucket. */
 	err = ntfs_sb_write_run(sbi, &ni->file.run, mirr_off, d_security,
-				aligned_sec_size);
+				aligned_sec_size, 0);
 	if (err)
 		goto out;
 
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 9f740fd301b2..e719036a7cea 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1586,7 +1586,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
 
 	/* Write non resident data. */
 	if (nsize) {
-		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize);
+		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize, 0);
 		if (err)
 			goto out7;
 	}
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 372cda697dd4..b030548faba2 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -434,7 +434,7 @@ bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le);
 bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
 		  const __le16 *name, size_t name_len,
 		  const struct MFT_REF *ref);
-int al_update(struct ntfs_inode *ni);
+int al_update(struct ntfs_inode *ni, int sync);
 static inline size_t al_aligned(size_t size)
 {
 	return (size + 1023) & ~(size_t)1023;
@@ -575,7 +575,7 @@ int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
 int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 		  const void *buffer, int wait);
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-		      u64 vbo, const void *buf, size_t bytes);
+		      u64 vbo, const void *buf, size_t bytes, int sync);
 struct buffer_head *ntfs_bread_run(struct ntfs_sb_info *sbi,
 				   const struct runs_tree *run, u64 vbo);
 int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run,
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 6f88cb77a17f..310743976d2c 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -444,7 +444,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
 		/* Delete xattr, ATTR_EA */
 		ni_remove_attr_le(ni, attr, mi, le);
 	} else if (attr->non_res) {
-		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size);
+		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
 		if (err)
 			goto out;
 	} else {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] fs/ntfs3: Speed up hardlink creation
  2021-09-13 15:09 [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Konstantin Komarov
                   ` (2 preceding siblings ...)
  2021-09-13 15:15 ` [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update Konstantin Komarov
@ 2021-09-18  7:01 ` Kari Argillander
  3 siblings, 0 replies; 8+ messages in thread
From: Kari Argillander @ 2021-09-18  7:01 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel

On Mon, Sep 13, 2021 at 06:09:42PM +0300, Konstantin Komarov wrote:
> xfstest generic/041 was taking some time before failing,
> so this series aims to fix it and speed up.
> Because of this we raise hardlinks limit to 4000.
> There are no drawbacks or regressions.
> Theoretically we can raise all the way up to ffff,
> but there is no practical use for this.

Hi. Sorry for taking so long. Did not notice that this is actually
another version. Please use v2 in subject. I did ask you to write little
bit more to commit "Change max hardlinks limit to 4000". Now you have
write it here. Cover letter will not be in commit messages. You need to
write this info to commit message also.

> 
> Konstantin Komarov (3):
>   fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext
>   fs/ntfs3: Change max hardlinks limit to 4000
>   fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update
> 
>  fs/ntfs3/attrib.c   | 2 +-
>  fs/ntfs3/attrlist.c | 6 +++---
>  fs/ntfs3/frecord.c  | 9 ++++++++-
>  fs/ntfs3/fslog.c    | 8 ++++----
>  fs/ntfs3/fsntfs.c   | 8 ++++----
>  fs/ntfs3/inode.c    | 2 +-
>  fs/ntfs3/ntfs.h     | 8 +++++---
>  fs/ntfs3/ntfs_fs.h  | 4 ++--
>  fs/ntfs3/xattr.c    | 2 +-
>  9 files changed, 29 insertions(+), 20 deletions(-)
> 
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext
  2021-09-13 15:12 ` [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext Konstantin Komarov
@ 2021-09-18  7:02   ` Kari Argillander
  0 siblings, 0 replies; 8+ messages in thread
From: Kari Argillander @ 2021-09-18  7:02 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel

On Mon, Sep 13, 2021 at 06:12:58PM +0300, Konstantin Komarov wrote:
> Do not try to insert attribute if there is no room in record.
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

Reviewed-by: Kari Argillander <kari.argillander@gmail.com>

> ---
>  fs/ntfs3/frecord.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 938b12d56ca6..834cb361f61f 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -956,6 +956,13 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le,
>  			continue;
>  		}
>  
> +		/*
> +		 * Do not try to insert this attribute
> +		 * if there is no room in record.
> +		 */
> +		if (le32_to_cpu(mi->mrec->used) + asize > sbi->record_size)
> +			continue;
> +
>  		/* Try to insert attribute into this subrecord. */
>  		attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize,
>  				       name_off, svcn, ins_le);
> -- 
> 2.33.0
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update
  2021-09-09 10:58 [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update Konstantin Komarov
@ 2021-09-09 12:53 ` Kari Argillander
  0 siblings, 0 replies; 8+ messages in thread
From: Kari Argillander @ 2021-09-09 12:53 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel

On Thu, Sep 09, 2021 at 01:58:08PM +0300, Konstantin Komarov wrote:
> This allows to wait only when it's requested.
> It speeds up creation of hardlinks.
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/attrib.c   | 2 +-
>  fs/ntfs3/attrlist.c | 6 +++---
>  fs/ntfs3/frecord.c  | 2 +-
>  fs/ntfs3/fslog.c    | 9 +++++----
>  fs/ntfs3/fsntfs.c   | 8 ++++----
>  fs/ntfs3/inode.c    | 2 +-
>  fs/ntfs3/ntfs_fs.h  | 4 ++--
>  fs/ntfs3/xattr.c    | 2 +-
>  8 files changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
> index 34c4cbf7e29b..64a28fe7c124 100644
> --- a/fs/ntfs3/attrib.c
> +++ b/fs/ntfs3/attrib.c
> @@ -291,7 +291,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
>  		if (!rsize) {
>  			/* Empty resident -> Non empty nonresident. */
>  		} else if (!is_data) {
> -			err = ntfs_sb_write_run(sbi, run, 0, data, rsize);
> +			err = ntfs_sb_write_run(sbi, run, 0, data, rsize, 0);
>  			if (err)
>  				goto out2;
>  		} else if (!page) {
> diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
> index fa32399eb517..e41443cb3d63 100644
> --- a/fs/ntfs3/attrlist.c
> +++ b/fs/ntfs3/attrlist.c
> @@ -336,7 +336,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
>  
>  	if (attr && attr->non_res) {
>  		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
> -					al->size);
> +					al->size, 0);
>  		if (err)
>  			return err;
>  		al->dirty = false;
> @@ -423,7 +423,7 @@ bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
>  	return true;
>  }
>  
> -int al_update(struct ntfs_inode *ni)
> +int al_update(struct ntfs_inode *ni, int sync)
>  {
>  	int err;
>  	struct ATTRIB *attr;
> @@ -445,7 +445,7 @@ int al_update(struct ntfs_inode *ni)
>  		memcpy(resident_data(attr), al->le, al->size);
>  	} else {
>  		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
> -					al->size);
> +					al->size, sync);
>  		if (err)
>  			goto out;
>  
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 5dd7b7a7c5e0..8478be3ab0e4 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3209,7 +3209,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
>  					goto out;
>  			}
>  
> -			err = al_update(ni);
> +			err = al_update(ni, sync);
>  			if (err)
>  				goto out;
>  		}
> diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
> index b5853aed0e25..5c82b6218d94 100644
> --- a/fs/ntfs3/fslog.c
> +++ b/fs/ntfs3/fslog.c
> @@ -2219,7 +2219,7 @@ static int last_log_lsn(struct ntfs_log *log)
>  
>  			err = ntfs_sb_write_run(log->ni->mi.sbi,
>  						&log->ni->file.run, off, page,
> -						log->page_size);
> +						log->page_size, 0);
>  
>  			if (err)
>  				goto out;
> @@ -3710,7 +3710,8 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
>  
>  	if (a_dirty) {
>  		attr = oa->attr;
> -		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes);
> +		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes,
> +					0);

If you don't mind that this is oneline I won't mind. 80 is limit, but
case like this imo checkpatch limit was raised to 100. So vote for this
becoming oneliner.

>  		if (err)
>  			goto out;
>  	}
> @@ -5152,10 +5153,10 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
>  
>  	ntfs_fix_pre_write(&rh->rhdr, log->page_size);
>  
> -	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size);
> +	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size, 0);
>  	if (!err)
>  		err = ntfs_sb_write_run(sbi, &log->ni->file.run, log->page_size,
> -					rh, log->page_size);
> +					rh, log->page_size, 0);
>  
>  	kfree(rh);
>  	if (err)
> diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> index 91e3743e1442..c89a0f5c5ad4 100644
> --- a/fs/ntfs3/fsntfs.c
> +++ b/fs/ntfs3/fsntfs.c
> @@ -1080,7 +1080,7 @@ int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
>  }
>  
>  int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
> -		      u64 vbo, const void *buf, size_t bytes)
> +		      u64 vbo, const void *buf, size_t bytes, int sync)
>  {
>  	struct super_block *sb = sbi->sb;
>  	u8 cluster_bits = sbi->cluster_bits;
> @@ -1100,7 +1100,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
>  
>  	for (;;) {
>  		u32 op = len < bytes ? len : bytes;
> -		int err = ntfs_sb_write(sb, lbo, op, buf, 0);
> +		int err = ntfs_sb_write(sb, lbo, op, buf, sync);
>  
>  		if (err)
>  			return err;
> @@ -2175,7 +2175,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
>  
>  	/* Write main SDS bucket. */
>  	err = ntfs_sb_write_run(sbi, &ni->file.run, sbi->security.next_off,
> -				d_security, aligned_sec_size);
> +				d_security, aligned_sec_size, 0);
>  
>  	if (err)
>  		goto out;
> @@ -2193,7 +2193,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
>  
>  	/* Write copy SDS bucket. */
>  	err = ntfs_sb_write_run(sbi, &ni->file.run, mirr_off, d_security,
> -				aligned_sec_size);
> +				aligned_sec_size, 0);
>  	if (err)
>  		goto out;
>  
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 187ef6adc9e1..aa519ed4453c 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -1593,7 +1593,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
>  
>  	/* Write non resident data. */
>  	if (nsize) {
> -		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize);
> +		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize, 0);
>  		if (err)
>  			goto out7;
>  	}
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index 97e682ebcfb9..a29578fa935b 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -436,7 +436,7 @@ bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le);
>  bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
>  		  const __le16 *name, size_t name_len,
>  		  const struct MFT_REF *ref);
> -int al_update(struct ntfs_inode *ni);
> +int al_update(struct ntfs_inode *ni, int sync);
>  static inline size_t al_aligned(size_t size)
>  {
>  	return (size + 1023) & ~(size_t)1023;
> @@ -577,7 +577,7 @@ int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
>  int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
>  		  const void *buffer, int wait);
>  int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
> -		      u64 vbo, const void *buf, size_t bytes);
> +		      u64 vbo, const void *buf, size_t bytes, int sync);
>  struct buffer_head *ntfs_bread_run(struct ntfs_sb_info *sbi,
>  				   const struct runs_tree *run, u64 vbo);
>  int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run,
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 83de1fd3b9c3..210a23979e71 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -444,7 +444,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
>  		/* Delete xattr, ATTR_EA */
>  		ni_remove_attr_le(ni, attr, mi, le);
>  	} else if (attr->non_res) {
> -		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size);
> +		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
>  		if (err)
>  			goto out;
>  	} else {
> -- 
> 2.28.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update
@ 2021-09-09 10:58 Konstantin Komarov
  2021-09-09 12:53 ` Kari Argillander
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-09 10:58 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

This allows to wait only when it's requested.
It speeds up creation of hardlinks.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/attrib.c   | 2 +-
 fs/ntfs3/attrlist.c | 6 +++---
 fs/ntfs3/frecord.c  | 2 +-
 fs/ntfs3/fslog.c    | 9 +++++----
 fs/ntfs3/fsntfs.c   | 8 ++++----
 fs/ntfs3/inode.c    | 2 +-
 fs/ntfs3/ntfs_fs.h  | 4 ++--
 fs/ntfs3/xattr.c    | 2 +-
 8 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 34c4cbf7e29b..64a28fe7c124 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -291,7 +291,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
 		if (!rsize) {
 			/* Empty resident -> Non empty nonresident. */
 		} else if (!is_data) {
-			err = ntfs_sb_write_run(sbi, run, 0, data, rsize);
+			err = ntfs_sb_write_run(sbi, run, 0, data, rsize, 0);
 			if (err)
 				goto out2;
 		} else if (!page) {
diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
index fa32399eb517..e41443cb3d63 100644
--- a/fs/ntfs3/attrlist.c
+++ b/fs/ntfs3/attrlist.c
@@ -336,7 +336,7 @@ int al_add_le(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name,
 
 	if (attr && attr->non_res) {
 		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-					al->size);
+					al->size, 0);
 		if (err)
 			return err;
 		al->dirty = false;
@@ -423,7 +423,7 @@ bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
 	return true;
 }
 
-int al_update(struct ntfs_inode *ni)
+int al_update(struct ntfs_inode *ni, int sync)
 {
 	int err;
 	struct ATTRIB *attr;
@@ -445,7 +445,7 @@ int al_update(struct ntfs_inode *ni)
 		memcpy(resident_data(attr), al->le, al->size);
 	} else {
 		err = ntfs_sb_write_run(ni->mi.sbi, &al->run, 0, al->le,
-					al->size);
+					al->size, sync);
 		if (err)
 			goto out;
 
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 5dd7b7a7c5e0..8478be3ab0e4 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3209,7 +3209,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
 					goto out;
 			}
 
-			err = al_update(ni);
+			err = al_update(ni, sync);
 			if (err)
 				goto out;
 		}
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index b5853aed0e25..5c82b6218d94 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -2219,7 +2219,7 @@ static int last_log_lsn(struct ntfs_log *log)
 
 			err = ntfs_sb_write_run(log->ni->mi.sbi,
 						&log->ni->file.run, off, page,
-						log->page_size);
+						log->page_size, 0);
 
 			if (err)
 				goto out;
@@ -3710,7 +3710,8 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
 
 	if (a_dirty) {
 		attr = oa->attr;
-		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes);
+		err = ntfs_sb_write_run(sbi, oa->run1, vbo, buffer_le, bytes,
+					0);
 		if (err)
 			goto out;
 	}
@@ -5152,10 +5153,10 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
 
 	ntfs_fix_pre_write(&rh->rhdr, log->page_size);
 
-	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size);
+	err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rh, log->page_size, 0);
 	if (!err)
 		err = ntfs_sb_write_run(sbi, &log->ni->file.run, log->page_size,
-					rh, log->page_size);
+					rh, log->page_size, 0);
 
 	kfree(rh);
 	if (err)
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index 91e3743e1442..c89a0f5c5ad4 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -1080,7 +1080,7 @@ int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 }
 
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-		      u64 vbo, const void *buf, size_t bytes)
+		      u64 vbo, const void *buf, size_t bytes, int sync)
 {
 	struct super_block *sb = sbi->sb;
 	u8 cluster_bits = sbi->cluster_bits;
@@ -1100,7 +1100,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
 
 	for (;;) {
 		u32 op = len < bytes ? len : bytes;
-		int err = ntfs_sb_write(sb, lbo, op, buf, 0);
+		int err = ntfs_sb_write(sb, lbo, op, buf, sync);
 
 		if (err)
 			return err;
@@ -2175,7 +2175,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
 	/* Write main SDS bucket. */
 	err = ntfs_sb_write_run(sbi, &ni->file.run, sbi->security.next_off,
-				d_security, aligned_sec_size);
+				d_security, aligned_sec_size, 0);
 
 	if (err)
 		goto out;
@@ -2193,7 +2193,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi,
 
 	/* Write copy SDS bucket. */
 	err = ntfs_sb_write_run(sbi, &ni->file.run, mirr_off, d_security,
-				aligned_sec_size);
+				aligned_sec_size, 0);
 	if (err)
 		goto out;
 
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 187ef6adc9e1..aa519ed4453c 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1593,7 +1593,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
 
 	/* Write non resident data. */
 	if (nsize) {
-		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize);
+		err = ntfs_sb_write_run(sbi, &ni->file.run, 0, rp, nsize, 0);
 		if (err)
 			goto out7;
 	}
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 97e682ebcfb9..a29578fa935b 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -436,7 +436,7 @@ bool al_remove_le(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le);
 bool al_delete_le(struct ntfs_inode *ni, enum ATTR_TYPE type, CLST vcn,
 		  const __le16 *name, size_t name_len,
 		  const struct MFT_REF *ref);
-int al_update(struct ntfs_inode *ni);
+int al_update(struct ntfs_inode *ni, int sync);
 static inline size_t al_aligned(size_t size)
 {
 	return (size + 1023) & ~(size_t)1023;
@@ -577,7 +577,7 @@ int ntfs_sb_read(struct super_block *sb, u64 lbo, size_t bytes, void *buffer);
 int ntfs_sb_write(struct super_block *sb, u64 lbo, size_t bytes,
 		  const void *buffer, int wait);
 int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
-		      u64 vbo, const void *buf, size_t bytes);
+		      u64 vbo, const void *buf, size_t bytes, int sync);
 struct buffer_head *ntfs_bread_run(struct ntfs_sb_info *sbi,
 				   const struct runs_tree *run, u64 vbo);
 int ntfs_read_run_nb(struct ntfs_sb_info *sbi, const struct runs_tree *run,
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 83de1fd3b9c3..210a23979e71 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -444,7 +444,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
 		/* Delete xattr, ATTR_EA */
 		ni_remove_attr_le(ni, attr, mi, le);
 	} else if (attr->non_res) {
-		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size);
+		err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
 		if (err)
 			goto out;
 	} else {
-- 
2.28.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-09-18  7:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 15:09 [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Konstantin Komarov
2021-09-13 15:12 ` [PATCH 1/3] fs/ntfs3: Fix insertion of attr in ni_ins_attr_ext Konstantin Komarov
2021-09-18  7:02   ` Kari Argillander
2021-09-13 15:14 ` [PATCH 2/3] fs/ntfs3: Change max hardlinks limit to 4000 Konstantin Komarov
2021-09-13 15:15 ` [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update Konstantin Komarov
2021-09-18  7:01 ` [PATCH 0/3] fs/ntfs3: Speed up hardlink creation Kari Argillander
  -- strict thread matches above, loose matches on Subject: below --
2021-09-09 10:58 [PATCH 3/3] fs/ntfs3: Add sync flag to ntfs_sb_write_run and al_update Konstantin Komarov
2021-09-09 12:53 ` Kari Argillander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).