From 6354467245ff8dd04b54e39790f2ee4d21d5419e Mon Sep 17 00:00:00 2001
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Date: Thu, 9 Sep 2021 13:15:20 +0300
Subject: [Backport 6354467245ff] src: Add sync flag to ntfs_sb_write_run
and al_update
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>
---
src/attrib.c | 2 +-
src/attrlist.c | 6 +++---
src/frecord.c | 2 +-
src/fslog.c | 8 ++++----
src/fsntfs.c | 8 ++++----
src/inode.c | 2 +-
src/ntfs_fs.h | 4 ++--
src/xattr.c | 2 +-
8 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/attrib.c b/src/attrib.c
index c15cc17e3cd92864f30fd0d3fbb8f20b98437cde..8a00fa978f5f9c3d496bd333bf1ace72d9194f37 100644
--- a/src/attrib.c
+++ b/src/attrib.c
@@ -287,7 +287,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/src/attrlist.c b/src/attrlist.c
index b9da527b96aa2ab00bf43d439d8527b587946a9d..bad6d8a849a24b3a4a9fc2c4c372496d6ac1b54a 100644
--- a/src/attrlist.c
+++ b/src/attrlist.c
@@ -333,7 +333,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;
@@ -420,7 +420,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;
@@ -442,7 +442,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/src/frecord.c b/src/frecord.c
index 0d00b2301a2f1fa380335ab91abd0afa53538053..9a53f809576d0b795ebb6ed2834792a60be463b0 100644
--- a/src/frecord.c
+++ b/src/frecord.c
@@ -3208,7 +3208,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/src/fslog.c b/src/fslog.c
index 6e7f9b72792b354a6e588b506c7352b286ed58bd..06492f088d6020592bd4fdb8b1a6ecd22b823324 100644
--- a/src/fslog.c
+++ b/src/fslog.c
@@ -2215,7 +2215,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;
@@ -3706,7 +3706,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;
}
@@ -5148,10 +5148,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/src/fsntfs.c b/src/fsntfs.c
index 77d2e56d5b4f34a693765d3230cf032122a04239..4de9acb1696898057fe3a096984ab3c6c1119810 100644
--- a/src/fsntfs.c
+++ b/src/fsntfs.c
@@ -1077,7 +1077,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;
@@ -1097,7 +1097,7 @@ int ntfs_sb_write_run(struct ntfs_sb_info *sbi, const struct runs_tree *run,
for (;;) {
u32 op = min_t(u64, 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;
@@ -2172,7 +2172,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;
@@ -2190,7 +2190,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/src/inode.c b/src/inode.c
index 33f278a0947ca23e103683b9daece8f539da355b..d583b71bec502f2042764e27f565e20be1858394 100644
--- a/src/inode.c
+++ b/src/inode.c
@@ -1584,7 +1584,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/src/ntfs_fs.h b/src/ntfs_fs.h
index dae6dd4ac6198fe735749b8e1405e110da4ddd62..6731b5d9e2d8efc742ce2200528e81eb22cbfa6e 100644
--- a/src/ntfs_fs.h
+++ b/src/ntfs_fs.h
@@ -465,7 +465,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;
@@ -606,7 +606,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/src/xattr.c b/src/xattr.c
index a8c5a899f0dd308fe5014bf3b384bc903ca0bf68..5c7c5c7a5ec1607cbe37c5cc6a847fd04a0d0464 100644
--- a/src/xattr.c
+++ b/src/xattr.c
@@ -441,7 +441,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.31.1