[Devel] [PATCH vz8] vdso, vclock_gettime: fix linking with old linkers

2020-11-09 Thread Andrey Ryabinin
On some old linkers vdso fails to build because of
dynamic reloction of 've_start_time' symbol:
VDSO2C  arch/x86/entry/vdso/vdso-image-64.c
Error: vdso image contains dynamic relocations

I was able to figure out why new linkers doesn't generate relocation
while old ones does, but I did find out that visibility("hidden")
attribute on 've_start_time' cures the problem.

https://jira.sw.ru/browse/PSBM-121668
Signed-off-by: Andrey Ryabinin 
---
 arch/x86/entry/vdso/vclock_gettime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/entry/vdso/vclock_gettime.c 
b/arch/x86/entry/vdso/vclock_gettime.c
index 224dbe80da66..b2f1f19319d8 100644
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vclock_gettime.c
@@ -24,7 +24,7 @@
 
 #define gtod ((vsyscall_gtod_data))
 
-u64 ve_start_time;
+u64 ve_start_time  __attribute__((visibility("hidden")));
 
 extern int __vdso_clock_gettime(clockid_t clock, struct timespec *ts);
 extern int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz);
-- 
2.26.2

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RH7 v2 2/2] ploop: Invalidate pagecache on service operations

2020-11-09 Thread Kirill Tkhai
This allows fastmap to work, otherwise it fails on
mapping_needs_writeback() check.

Signed-off-by: Kirill Tkhai 
---
 drivers/block/ploop/io_kaio.c |   22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index be74b2ec344f..112fd92acb40 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -937,6 +937,15 @@ static int kaio_alloc_sync(struct ploop_io * io, loff_t 
pos, loff_t len)
 
return err;
 }
+static int kaio_invalidate_cache(struct ploop_io *io)
+{
+   struct inode *inode = io->files.inode;
+
+   if (!inode->i_op->fastmap)
+   return 0;
+
+   return invalidate_inode_pages2(io->files.mapping);
+}
 
 static int kaio_open(struct ploop_io * io)
 {
@@ -952,6 +961,7 @@ static int kaio_open(struct ploop_io * io)
io->files.bdev = io->files.inode->i_sb->s_bdev;
 
mutex_lock(>files.inode->i_mutex);
+   kaio_invalidate_cache(io);
err = ploop_kaio_open(file, delta->flags & PLOOP_FMT_RDONLY);
mutex_unlock(>files.inode->i_mutex);
 
@@ -1004,6 +1014,10 @@ static int kaio_prepare_snapshot(struct ploop_io * io, 
struct ploop_snapdata *sd
return err;
}
 
+   mutex_lock(>files.inode->i_mutex);
+   kaio_invalidate_cache(io);
+   mutex_unlock(>files.inode->i_mutex);
+
sd->file = file;
return 0;
 }
@@ -1024,6 +1038,10 @@ static int kaio_complete_snapshot(struct ploop_io * io, 
struct ploop_snapdata *s
 
ploop_kaio_downgrade(io->files.mapping);
 
+   mutex_lock(>files.inode->i_mutex);
+   kaio_invalidate_cache(io);
+   mutex_unlock(>files.inode->i_mutex);
+
if (io->fsync_thread) {
kthread_stop(io->fsync_thread);
io->fsync_thread = NULL;
@@ -1057,6 +1075,10 @@ static int kaio_prepare_merge(struct ploop_io * io, 
struct ploop_snapdata *sd)
if (err)
goto prep_merge_done;
 
+   mutex_lock(>files.inode->i_mutex);
+   kaio_invalidate_cache(io);
+   mutex_unlock(>files.inode->i_mutex);
+
err = ploop_kaio_upgrade(io->files.mapping);
if (err)
goto prep_merge_done;


___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RH7 v2 1/2] ploop: Add statistics of fastmap requests, which fails because of cache

2020-11-09 Thread Kirill Tkhai
Normally, mapping_needs_writeback() should not be true. But in case
of some problem, or userspace touch root.hds without direct mode,
cache may populate. Count such the failed fastmaps.

Signed-off-by: Kirill Tkhai 
---
 drivers/block/ploop/io_kaio.c|2 ++
 fs/ext4/file.c   |5 -
 include/linux/ploop/ploop_stat.h |1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 4c4a0c6a908c..be74b2ec344f 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -1236,6 +1236,8 @@ kaio_fastmap(struct ploop_io *io, struct bio *orig_bio,
   orig_bio->bi_rw & REQ_WRITE);
if (ret < 0) {
io->plo->st.fast_neg_noem++;
+   if (ret == -EBUSY)
+   io->plo->st.write_back_pending++;
return 1;
}
 
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 8f5fb6d99d5e..67a385e9f716 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -132,6 +132,7 @@ static int ext4_fastmap(struct inode *inode, sector_t 
lblk_sec,
bool unaligned_aio, found, locked = false;
struct ext4_map_blocks map;
loff_t pos = lblk_sec << 9;
+   int err;
 
if (!S_ISREG(inode->i_mode))
return -ENOENT;
@@ -152,6 +153,7 @@ static int ext4_fastmap(struct inode *inode, sector_t 
lblk_sec,
locked = true;
}
 
+   err = -EBUSY;
if (unlikely(mapping_needs_writeback(mapping)))
goto err_maybe_unlock;
 
@@ -163,6 +165,7 @@ static int ext4_fastmap(struct inode *inode, sector_t 
lblk_sec,
locked = false;
}
 
+   err = -ENOENT;
if (unlikely(ext4_test_inode_state(inode,
EXT4_STATE_DIOREAD_LOCK))) {
goto err_dio_end;
@@ -181,7 +184,7 @@ static int ext4_fastmap(struct inode *inode, sector_t 
lblk_sec,
 err_maybe_unlock:
if (locked)
mutex_unlock(>i_mutex);
-   return -ENOENT;
+   return err;
 }
 
 static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *iter, 
loff_t *pos)
diff --git a/include/linux/ploop/ploop_stat.h b/include/linux/ploop/ploop_stat.h
index bed910acb39c..92543a9afe88 100644
--- a/include/linux/ploop/ploop_stat.h
+++ b/include/linux/ploop/ploop_stat.h
@@ -34,6 +34,7 @@ __DO(merge_neg_cluster)
 __DO(merge_neg_disable)
 __DO(fast_neg_nomap)
 __DO(fast_neg_noem)
+__DO(write_back_pending)
 __DO(fast_neg_shortem)
 __DO(fast_neg_backing)
 __DO(bio_lockouts)


___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel