[Devel] [PATCH RHEL7 COMMIT] fs/fuse: set FATTR_FH flag on mtime file flush

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 6e5c2cf88453446fee1320c7c1af3d35364fb694
Author: Pavel Butsykin 
Date:   Mon Jun 4 23:26:15 2018 +0300

fs/fuse: set FATTR_FH flag on mtime file flush

If setattr request is for a file, FATTR_FH flag should be set.
In fuse_flush_mtime() that is clearly missed.

This fix is present in ms commit 1e18bda86e2d ("fuse: add .write_inode"), 
but
it wasn't backported because the commit has a lot of unrelated changes. So 
this
patch can be safely dropped in case of moving to a newer kernel.

https://pmc.acronis.com/browse/VSTOR-10676

Signed-off-by: Pavel Butsykin 
---
 fs/fuse/dir.c| 6 +-
 fs/fuse/file.c   | 4 ++--
 fs/fuse/fuse_i.h | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0ae0344be3c5..b04023bf230a 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1690,7 +1690,7 @@ static void fuse_setattr_fill(struct fuse_conn *fc, 
struct fuse_req *req,
 /*
  * Flush inode->i_mtime to the server
  */
-int fuse_flush_mtime(struct file *file, bool nofail)
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail)
 {
struct inode *inode = file->f_mapping->host;
struct fuse_inode *fi = get_fuse_inode(inode);
@@ -1715,6 +1715,10 @@ int fuse_flush_mtime(struct file *file, bool nofail)
inarg.mtime = inode->i_mtime.tv_sec;
inarg.mtimensec = inode->i_mtime.tv_nsec;
 
+   if (ff) {
+   inarg.valid |= FATTR_FH;
+   inarg.fh = ff->fh;
+   }
fuse_setattr_fill(fc, req, inode, , );
fuse_request_send(fc, req);
err = req->out.h.error;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d84dd402c83c..f9a0da25a9df 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -458,7 +458,7 @@ static int fuse_release(struct inode *inode, struct file 
*file)
 
if (test_bit(FUSE_I_MTIME_UPDATED,
 _fuse_inode(inode)->state))
-   fuse_flush_mtime(file, true);
+   fuse_flush_mtime(file, ff, true);
 
fuse_release_common(file, FUSE_RELEASE);
 
@@ -731,7 +731,7 @@ int fuse_fsync_common(struct file *file, loff_t start, 
loff_t end,
 
if (!datasync && test_bit(FUSE_I_MTIME_UPDATED,
  _fuse_inode(inode)->state)) {
-   err = fuse_flush_mtime(file, false);
+   err = fuse_flush_mtime(file, isdir ? NULL : ff, false);
if (err)
goto out;
}
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index f704fd17905b..939835f585b1 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1074,7 +1074,7 @@ int fuse_dev_release(struct inode *inode, struct file 
*file);
 
 bool fuse_write_update_size(struct inode *inode, loff_t pos);
 
-int fuse_flush_mtime(struct file *file, bool nofail);
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail);
 
 int fuse_do_setattr(struct inode *inode, struct iattr *attr,
struct file *file);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: Wait till cs is unused in pcs_csset_fini()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 2c1c2d3e8162cc6e17afccc82a33a40481da6d5e
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:15 2018 +0300

fuse kio: Wait till cs is unused in pcs_csset_fini()

This is the second function, which can isolate a cs.
Despite it's unused now, I add waiting use_count here
for uniformity and for the future use.

After this, all the code will know we can't isolate
a cs if someone uses it.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_cs.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 5cf7d73de67b..9614f2473629 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -1059,6 +1059,18 @@ void pcs_csset_init(struct pcs_cs_set *css)
atomic64_set(>csl_serno_gen, 0);
 }
 
+static void pcs_cs_wait_unused(struct pcs_cs *cs)
+{
+   assert_spin_locked(>lock);
+   cs->use_count++;
+   while (cs->use_count != 1) {
+   spin_unlock(>lock);
+   schedule_timeout(1);
+   spin_lock(>lock);
+   }
+   cs->use_count--;
+}
+
 void pcs_csset_fini(struct pcs_cs_set *css)
 {
unsigned int i;
@@ -1082,6 +1094,7 @@ void pcs_csset_fini(struct pcs_cs_set *css)
continue;
}
rcu_read_unlock();
+   pcs_cs_wait_unused(cs);
pcs_cs_isolate(cs, _resubmit);
spin_unlock(>lock);
pcs_cs_destroy(cs);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: Introduce pcs_cs::use_count instead of ::is_probing

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit e6b0bf08eaa2b09c9d560c8db76641087c596f88
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:14 2018 +0300

fuse kio: Introduce pcs_cs::use_count instead of ::is_probing

This patch generalizes is_probing and this allows to prohibit
cs isolation after unlocking of cs::lock, not only in bl_timer_work().

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_cs.c | 10 +-
 fs/fuse/kio/pcs/pcs_cs.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 0b6c4f248251..5cf7d73de67b 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -82,7 +82,7 @@ struct pcs_cs *pcs_cs_alloc(struct pcs_cs_set *css,
cs->nflows = 0;
 
cs->state = 0;
-   cs->is_probing = 0;
+   cs->use_count = 0;
cs->is_dead = 0;
INIT_LIST_HEAD(>bl_link);
 
@@ -957,7 +957,7 @@ static void cs_probe_done(struct pcs_msg *msg)
TRACE("probe error %d", msg->error.value);
cs_blacklist(cs, msg->error.value, "probe");
}
-   cs->is_probing = 0;
+   cs->use_count--;
}
spin_unlock(>lock);
pcs_free_msg(msg);
@@ -1015,7 +1015,7 @@ static void bl_timer_work(struct work_struct *w)
spin_lock(>lock);
BUG_ON(cs->is_dead);
list_move(>bl_link, _blacklist);
-   if (cs->is_probing) {
+   if (cs->use_count) {
spin_unlock(>lock);
continue;
}
@@ -1025,14 +1025,14 @@ static void bl_timer_work(struct work_struct *w)
pcs_cs_destroy(cs);
continue;
}
-   cs->is_probing = 1;
+   cs->use_count++;
spin_unlock(>lock);
msg = cs_prep_probe(cs);
if (msg)
pcs_rpc_call(cs->rpc, msg);
spin_lock(>lock);
if (!msg)
-   cs->is_probing = 0;
+   cs->use_count--;
spin_unlock(>lock);
}
spin_lock(>lock);
diff --git a/fs/fuse/kio/pcs/pcs_cs.h b/fs/fuse/kio/pcs/pcs_cs.h
index eb81ac51f3ae..1fb40936d046 100644
--- a/fs/fuse/kio/pcs/pcs_cs.h
+++ b/fs/fuse/kio/pcs/pcs_cs.h
@@ -76,8 +76,8 @@ struct pcs_cs {
 
unsigned long   state;
int blacklist_reason;
+   unsigned intuse_count; /* Protects cs against isolation */
struct list_headbl_link;
-   unsignedis_probing:1;
unsignedis_dead:1;
 
 
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: Fix possible use after free in cslist_destroy()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit bd49d2ba5358a87aa6bdf00a6bbdb817902c8c94
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:14 2018 +0300

fuse kio: Fix possible use after free in cslist_destroy()

This can race with pcs_csset_fini():

pcs_csset_fini()   cslist_destroy()
 if (!cslink->cs) <- compiler caches cslink->cs
  pcs_cs_isolate()
  pcs_cs_destroy()
 spin_lock(>cs->lock) <- use after free

Fix that.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_cs.c  |  2 +-
 fs/fuse/kio/pcs/pcs_map.c | 11 +++
 fs/fuse/kio/pcs/pcs_map.h |  2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 899bf5c9f650..0b6c4f248251 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -728,7 +728,7 @@ static void pcs_cs_isolate(struct pcs_cs *cs, struct 
list_head *dispose)
struct pcs_cs_link *csl = list_first_entry(>map_list,
   struct 
pcs_cs_link,
   link);
-   csl->cs = NULL;
+   rcu_assign_pointer(csl->cs, NULL);
cs->nmaps--;
list_del_init(>link);
}
diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index ef4efa6cc13e..56a1118af255 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -60,20 +60,23 @@ static void cslist_destroy(struct pcs_cs_list * csl)
TRACE("csl:%p csl->map:%p refcnt:%d\n", csl, csl->map, 
atomic_read(>refcnt));
BUG_ON(csl->map);
 
+   rcu_read_lock();
for (i = 0; i < csl->nsrv; i++) {
struct pcs_cs_link * cslink = >cs[i].cslink;
+   struct pcs_cs __rcu *cs = rcu_dereference(cslink->cs);
 
/* Possible after error inside cslist_alloc() */
-   if (!cslink->cs)
+   if (!cs)
continue;
 
-   spin_lock(>cs->lock);
+   spin_lock(>lock);
if (!list_empty(>link)) {
list_del_init(>link);
-   cslink->cs->nmaps--;
+   cs->nmaps--;
}
spin_unlock(>cs->lock);
}
+   rcu_read_unlock();
kfree(csl);
 }
 
@@ -948,7 +951,7 @@ struct pcs_cs_list* cslist_alloc( struct pcs_cs_set *css, 
struct pcs_cs_info *re
assert_spin_locked(>lock);
BUG_ON(cs->is_dead);
 
-   cslink->cs = cs;
+   rcu_assign_pointer(cslink->cs, cs);
cslink->addr_serno = cs->addr_serno;
 
cs->io_prio = cs_list->cs[i].info.io_prio;
diff --git a/fs/fuse/kio/pcs/pcs_map.h b/fs/fuse/kio/pcs/pcs_map.h
index 49a05ff625f4..bc6874a2ebc2 100644
--- a/fs/fuse/kio/pcs/pcs_map.h
+++ b/fs/fuse/kio/pcs/pcs_map.h
@@ -26,7 +26,7 @@ struct pcs_int_request;
 
 

[Devel] [PATCH RHEL7 COMMIT] fuse kio: Introduce pcs_cs_list_of_cs_link()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit a35df0c623c9ccf81a75e0755c883c524aed6780
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:13 2018 +0300

fuse kio: Introduce pcs_cs_list_of_cs_link()

Pack repeating patterns in a separate function.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_map.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index e649a9b5efb5..56b660849a80 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -26,6 +26,16 @@
 */
 #define MAP_BATCH 16
 
+static struct pcs_cs_list *cs_link_to_cs_list(struct pcs_cs_link *csl)
+{
+   struct pcs_cs_record *cs_rec;
+   struct pcs_cs_list *cs_list;
+
+   cs_rec = container_of(csl, struct pcs_cs_record, cslink);
+   cs_list = container_of(cs_rec - csl->index, struct pcs_cs_list, cs[0]);
+   return cs_list;
+}
+
 static void pcs_ireq_queue_fail(struct list_head *queue, int error);
 
 abs_time_t get_real_time_ms(void)
@@ -550,12 +560,10 @@ static void map_recalc_maps(struct pcs_cs * cs)
assert_spin_locked(>lock);
 
list_for_each_entry(csl, >map_list, link) {
-   struct pcs_cs_record * cs_rec;
-   struct pcs_cs_list * cs_list;
+   struct pcs_cs_list *cs_list;
int read_idx;
 
-   cs_rec = container_of(csl, struct pcs_cs_record, cslink);
-   cs_list = container_of(cs_rec - csl->index, struct pcs_cs_list, 
cs[0]);
+   cs_list = cs_link_to_cs_list(csl);
read_idx = READ_ONCE(cs_list->read_index);
 
if (read_idx >= 0 && (!cs_is_blacklisted(cs) ||
@@ -570,12 +578,10 @@ void pcs_map_force_reselect(struct pcs_cs * cs)
assert_spin_locked(>lock);
 
list_for_each_entry(csl, >map_list, link) {
-   struct pcs_cs_record * cs_rec;
-   struct pcs_cs_list * cs_list;
+   struct pcs_cs_list *cs_list;
int read_idx;
 
-   cs_rec = container_of(csl, struct pcs_cs_record, cslink);
-   cs_list = container_of(cs_rec - csl->index, struct pcs_cs_list, 
cs[0]);
+   cs_list = cs_link_to_cs_list(csl);
read_idx = READ_ONCE(cs_list->read_index);
 
if (read_idx >= 0 && cs_list->cs[read_idx].cslink.cs == cs)
@@ -606,11 +612,9 @@ static int urgent_whitelist(struct pcs_cs * cs)
assert_spin_locked(>lock);
 
list_for_each_entry(csl, >map_list, link) {
-   struct pcs_cs_record * cs_rec;
-   struct pcs_cs_list * cs_list;
+   struct pcs_cs_list *cs_list;
 
-   cs_rec = container_of(csl, struct pcs_cs_record, cslink);
-   cs_list = container_of(cs_rec - csl->index, struct pcs_cs_list, 
cs[0]);
+   cs_list = cs_link_to_cs_list(csl);
 
if (cs_list->map == NULL)
continue;
@@ -694,16 +698,12 @@ void 

[Devel] [PATCH RHEL7 COMMIT] fuse kio: Change order around pcs_map_notify_addr_change()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 885971b6a2d878fff83b5709a96b5d6171fbab7d
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:15 2018 +0300

fuse kio: Change order around pcs_map_notify_addr_change()

This unblacklistes a cs after all maps are marked as stale,
while rpc addr becomes assigned earlier.

Since pcs_rpc::addr is dereferenced with cs unlocked,
it seems, we can may such the change.
This will be used in next patch.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_cs.c  | 7 +--
 fs/fuse/kio/pcs/pcs_map.c | 2 --
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 9614f2473629..27f0bc3754d9 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -193,11 +193,14 @@ struct pcs_cs *pcs_cs_find_create(struct pcs_cs_set 
*csset, PCS_NODE_ID_T *id, P
if (pcs_netaddr_cmp(>addr, addr)) {
cs->addr = *addr;
cs->addr_serno++;
-   if (!(flags & CS_FL_INACTIVE))
-   pcs_map_notify_addr_change(cs);
+
TRACE("Port change CS" NODE_FMT " seq=%d", 
NODE_ARGS(*id), cs->addr_serno);
pcs_rpc_set_address(cs->rpc, addr);
 
+   if (!(flags & CS_FL_INACTIVE)) {
+   pcs_map_notify_addr_change(cs);
+   cs_whitelist(cs, "addr update");
+   }
}
}
/* TODO: (flags & PCS_RPC_F_LOCAL) should be checker here */
diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 56a1118af255..49af8b961478 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -699,8 +699,6 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
struct pcs_cs_link * csl;
assert_spin_locked(>lock);
 
-   cs_whitelist(cs, "addr update");
-
rcu_read_lock();
list_for_each_entry(csl, >map_list, link) {
struct pcs_cs_list *cs_list;
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: Fix fix deadlock during change CS address

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 1bb9d8c41e7079ac798184ab1fe539c8e28761b6
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:16 2018 +0300

fuse kio: Fix fix deadlock during change CS address

We have noticed the following deadlock:

map_truncate_tail() pcs_cs_find_create()
  spin_lock(>lock) spin_lock(>lock)
  map_drop_cslist()   pcs_map_notify_addr_change()
cslist_destroy()spin_lock(>lock)
  spin_lock(>lock)

To fix it, this patch makes pcs_map_notify_addr_change()
to unlock the cs->lock before taking m->lock. This is
possible because of cs_list can't be unlinked from the list
after the unlock: we take cs_list counter to keep it alive,
and increment cs->use_count to prohibit cs isolation. Thus,
after we taken the lock again, cs_link is guatanteed to be
on the place, and we continue the iterations.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_map.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 49af8b961478..650da306b055 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -696,12 +696,14 @@ static void map_remote_error(struct pcs_map_entry *m , 
int error, u64 offender)
 
 void pcs_map_notify_addr_change(struct pcs_cs * cs)
 {
+   struct pcs_cs_list *cs_list, *prev_cs_list = NULL;
struct pcs_cs_link * csl;
assert_spin_locked(>lock);
 
+   cs->use_count++; /* Prohibit to isolate cs */
+
rcu_read_lock();
list_for_each_entry(csl, >map_list, link) {
-   struct pcs_cs_list *cs_list;
struct pcs_map_entry *m;
 
if (csl->addr_serno == cs->addr_serno)
@@ -710,6 +712,18 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
m = rcu_dereference(cs_list->map);
if (!m)
continue;
+   /*
+* Get cs_list to prevent its destruction and unlinking from cs.
+* Thus, csl stays on the place in the list. New elements may be
+* added to head of cs->map_list, so our caller must care, they
+* will contain correct rpc addr.
+*/
+   cslist_get(cs_list);
+   spin_unlock(>lock);
+
+   if (prev_cs_list)
+   cslist_put(prev_cs_list);
+   prev_cs_list = cs_list;
 
spin_lock(>lock);
if ((m->state & PCS_MAP_DEAD) || m->cs_list != cs_list)
@@ -724,8 +738,17 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
map_remote_error_nolock(m, PCS_ERR_CSD_STALE_MAP, cs->id.val);
 unlock:
spin_unlock(>lock);
+   spin_lock(>lock);
+   }
+
+   if (prev_cs_list) {
+   spin_unlock(>lock);
+   cslist_put(prev_cs_list);
+   spin_lock(>lock);
}
   

[Devel] [PATCH RHEL7 COMMIT] fuse kio: Fix potential use after free

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit f374a9cb41c9d7c11f233a890844ed3604fe92fd
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:24:14 2018 +0300

fuse kio: Fix potential use after free

pcs_map_notify_addr_change() must take rcu_read_lock()
while dereferencing of cs_list->map. Otherwise, it can
be freed in parallel.

This patch adds rcu_read_lock() protection and __rcu
midifier.

Signed-off-by: Kirill Tkhai 

=
Patchset description:

Fix deadlock during change of CS address

This is not a complete patchset, but I meet the situation
when it's necessary to change original logic in small way,
so this is a request for comments.

[1-5/7] are mostly preparations and fixes, so my question
is about [6-7/7].

1) Patch 6 changes order of actions: pcs_map_notify_addr_change()
is called after assigning of rpc addr. Can we do that? As I
understand this results in new maps are created with new address,
while in pcs_map_notify_addr_change() we invalidate old ones.
So, for me it seems there is no a problem.

This is needed for possibility to unlock cs->lock in 
pcs_map_notify_addr_change().
Theoretically, two pcs_cs_find_create() may happen in parallel,
so we want they assign addr in the order they happen. Otherwise,
the first one with the old addr_serno may overwrite the addr.

2) Patch 7 uses the preparations from previous patches and
makes pcs_map_notify_addr_change() to unlock cs->lock for a while.
New elements are added to head of cs->map_list, so we skip
them on iterations. But it seems, they must be correct because
we already updated rpc addr in pcs_cs_find_create(). Is there
a reason we can't do this?

Kirill Tkhai (7):
  fuse kio: Introduce pcs_cs_list_of_cs_link()
  fuse kio: Fix potential use after free
  fuse kio: Fix possible use after free in cslist_destroy()
  fuse kio: Introduce pcs_cs::use_count instead of ::is_probing
  fuse kio: Wait till cs is unused in pcs_csset_fini()
  fuse kio: Change order around pcs_map_notify_addr_change()
  fuse kio: Fix fix deadlock during change CS address
---
 fs/fuse/kio/pcs/pcs_map.c | 13 -
 fs/fuse/kio/pcs/pcs_map.h |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 56b660849a80..ef4efa6cc13e 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -97,7 +97,7 @@ static void map_drop_cslist(struct pcs_map_entry * m)
if (m->cs_list == NULL)
return;
 
-   m->cs_list->map = NULL;
+   rcu_assign_pointer(m->cs_list->map, NULL);
/* Barrier here is only for sanity checks in cslist_destroy() */
smp_mb__before_atomic_dec();
cslist_put(m->cs_list);
@@ -616,6 +616,7 @@ static int urgent_whitelist(struct pcs_cs * cs)
 
cs_list = cs_link_to_cs_list(csl);
 
+   /* FIXME: do we need rcu here? */
if (cs_list->map == NULL)
continue;
 
@@ -697,6 +698,7 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
 
cs_whitelist(cs, "addr update");
 
+   rcu_read_lock();
list_for_each_entry(csl, >map_list, link) {
struct pcs_cs_list *cs_list;
struct pcs_map_entry *m;
@@ -704,7 +706,8 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
if (csl->addr_serno == cs->addr_serno)
continue;
cs_list = cs_link_to_cs_list(csl);
-   if ((m = cs_list->map) == NULL)
+   m = rcu_dereference(cs_list->map);
+   if (!m)
continue;
 
spin_lock(>lock);
@@ -718,10 +721,10 @@ void pcs_map_notify_addr_change(struct pcs_cs * cs)
  MAP_ARGS(m), NODE_ARGS(cs->id));
 
map_remote_error_nolock(m, PCS_ERR_CSD_STALE_MAP, cs->id.val);
-   unlock:
+unlock:
spin_unlock(>lock);
-
}
+   rcu_read_unlock();
 }
 
 noinline static void pcs_ireq_queue_fail(struct list_head *queue, int error)
@@ -1045,7 +1048,7 @@ void pcs_map_complete(struct pcs_map_entry *m, struct 
pcs_ioc_getmap *omap)
transfer_sync_data(cs_list, m->cs_list);
map_drop_cslist(m);
}
-   cs_list->map = m;
+   rcu_assign_pointer(cs_list->map, m);
cs_list->version = m->version;
m->cs_list = cs_list;
cs_list = NULL;
diff --git a/fs/fuse/kio/pcs/pcs_map.h b/fs/fuse/kio/pcs/pcs_map.h
index c60e72b365d3..49a05ff625f4 100644
--- a/fs/fuse/kio/pcs/pcs_map.h
+++ b/fs/fuse/kio/pcs/pcs_map.h
@@ 

[Devel] [PATCH RHEL7 COMMIT] kernel/panic.c: don't dump_stack() in add_taint()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 3b2f6f50b6f6ac36a3b41357d1f2905970f17e63
Author: Andrey Ryabinin 
Date:   Mon Jun 4 23:14:45 2018 +0300

kernel/panic.c: don't dump_stack() in add_taint()

add_taint() callers usually call dump_stack(). The second
dump_stack() only polutes the log.

This effectively reverts:
a636e01ad813 ("FIXME: to drop: ve/kernel/taint: Port 
diff-taint-message-enhanced-with-dump")

Signed-off-by: Andrey Ryabinin 
---
 kernel/panic.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 333e36cd1175..6d33011078d2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -387,12 +387,6 @@ void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
printk(KERN_WARNING
   "Disabling lock debugging due to kernel taint\n");
 
-   /* Do not confuse people with calltraces on proprietary modules */
-   if (flag != TAINT_PROPRIETARY_MODULE && flag != TAINT_OOT_MODULE &&
-   flag != TAINT_UNSIGNED_MODULE) {
-   printk(KERN_WARNING "Tainting kernel with flag 0x%x\n", flag);
-   dump_stack();
-   }
set_bit(flag, _mask);
 }
 EXPORT_SYMBOL(add_taint);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] mm/memcg: Remove development debug printk

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit dd4244fa9062d3475ce375997d89c542a8b5fb90
Author: Andrey Ryabinin 
Date:   Mon Jun 4 23:14:46 2018 +0300

mm/memcg: Remove development debug printk

Remove some debugging printk that accidentally sneaked
in patch "mm/memcg: Don't charge anon pages as cache"

Fixes: 3222682e7468 mm/memcg: ("Don't charge anon pages as cache")

Signed-off-by: Andrey Ryabinin 
---
 mm/memcontrol.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 65c069a1eeae..ad05bf68e770 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6988,12 +6988,8 @@ static int __mem_cgroup_try_charge(struct page *page, 
struct mm_struct *mm,
goto out;
}
 
-   if (PageTransHuge(page)) {
+   if (PageTransHuge(page))
nr_pages <<= compound_order(page);
-   if (!PageAnon(page)) {
-   pr_warn_once("page->flags %lx page %p head %p", 
page->flags, page, compound_head(page));
-   }
-   }
 
if (do_swap_account && PageSwapCache(page))
memcg = try_get_mem_cgroup_from_page(page);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: Remove useless code in pcs_cs_destroy()

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 2e39d2db8037edfdcec6a293549438edb3e54be6
Author: Kirill Tkhai 
Date:   Mon Jun 4 23:05:51 2018 +0300

fuse kio: Remove useless code in pcs_cs_destroy()

We have kfree_rcu() for a long time in kernel.

Signed-off-by: Kirill Tkhai 
---
 fs/fuse/kio/pcs/pcs_cs.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index cae591e65a42..899bf5c9f650 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -741,13 +741,6 @@ static void pcs_cs_isolate(struct pcs_cs *cs, struct 
list_head *dispose)
BUG_ON(cs->nflows);
 }
 
-static void cs_free_callback(struct rcu_head *head)
-{
-   struct pcs_cs *cs = container_of(head, struct pcs_cs, rcu);
-
-   kfree(cs);
-}
-
 static void pcs_cs_destroy(struct pcs_cs *cs)
 {
BUG_ON(!list_empty(>active_list));
@@ -758,10 +751,9 @@ static void pcs_cs_destroy(struct pcs_cs *cs)
pcs_rpc_close(cs->rpc);
cs->rpc = NULL;
}
-   call_rcu(>rcu, cs_free_callback);
+   kfree_rcu(cs, rcu);
 }
 
-
 void cs_aborting(struct pcs_rpc *ep, int error)
 {
pcs_rpc_reset(ep);
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: invalid assertion

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 5a62f4c43bcf84e10e64852692341d2595484da9
Author: Alexey Kuznetsov 
Date:   Mon Jun 4 23:05:51 2018 +0300

fuse kio: invalid assertion

rpc address _is_ changed while rpc is still connected.
User space have the same assertion commented from day zero.
No idea why it was uncommented here.

Signed-off-by: Alexey Kuznetsov 

Signed-off-by: Kirill Tkhai 
---
 fs/fuse/kio/pcs/pcs_rpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index 2c7bd74e5784..9977661b1e11 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -1134,7 +1134,7 @@ void pcs_rpc_set_peer_id(struct pcs_rpc * ep, 
PCS_NODE_ID_T * id, u8 role)
 
 int pcs_rpc_set_address(struct pcs_rpc * ep, PCS_NET_ADDR_T * addr)
 {
-   BUG_ON(ep->state != PCS_RPC_UNCONN);
+// BUG_ON(ep->state != PCS_RPC_UNCONN);
 
ep->addr = *addr;
return 0;
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] fuse kio: cleanup in token enqueue

2018-06-04 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
-->
commit 0bf934240c56649bb58d0df43b0e875bd27862f9
Author: Alexey Kuznetsov 
Date:   Mon Jun 4 23:05:50 2018 +0300

fuse kio: cleanup in token enqueue

In case of skipping token mark this CS as passed congestion check.
Otherwise at the next round we will try wait again. It is not a real bug,
but still some inconsistency.

Signed-off-by: Alexey Kuznetsov 

Signed-off-by: Kirill Tkhai 
---
 fs/fuse/kio/pcs/pcs_map.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 90e311f7e995..e649a9b5efb5 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -1966,6 +1966,7 @@ static int ireq_queue_tokens(struct pcs_int_request * 
ireq, struct pcs_cs_list *
   toks[i] = NULL;
   queued = 1;
   } else {
+  ireq->tok_reserved |= (1ULL << i);
   list_add([i]->token.tok_link, );
   }
   }
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH] fs/fuse: set FATTR_FH flag on mtime file flush

2018-06-04 Thread Pavel Butsykin
If setattr request is for a file, FATTR_FH flag should be set.
In fuse_flush_mtime() that is clearly missed.

This fix is present in commit 1e18bda, but it wasn't backported because
the commit has a lot of unrelated changes. So this patch can be safely dropped
in case of moving to a newer kernel.

#VSTOR-10676

Signed-off-by: Pavel Butsykin 
---
 fs/fuse/dir.c| 6 +-
 fs/fuse/file.c   | 4 ++--
 fs/fuse/fuse_i.h | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0ae0344be3c5..b04023bf230a 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1690,7 +1690,7 @@ static void fuse_setattr_fill(struct fuse_conn *fc, 
struct fuse_req *req,
 /*
  * Flush inode->i_mtime to the server
  */
-int fuse_flush_mtime(struct file *file, bool nofail)
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail)
 {
struct inode *inode = file->f_mapping->host;
struct fuse_inode *fi = get_fuse_inode(inode);
@@ -1715,6 +1715,10 @@ int fuse_flush_mtime(struct file *file, bool nofail)
inarg.mtime = inode->i_mtime.tv_sec;
inarg.mtimensec = inode->i_mtime.tv_nsec;
 
+   if (ff) {
+   inarg.valid |= FATTR_FH;
+   inarg.fh = ff->fh;
+   }
fuse_setattr_fill(fc, req, inode, , );
fuse_request_send(fc, req);
err = req->out.h.error;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 53e81bdca6ed..ddfb41af54ec 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -458,7 +458,7 @@ static int fuse_release(struct inode *inode, struct file 
*file)
 
if (test_bit(FUSE_I_MTIME_UPDATED,
 _fuse_inode(inode)->state))
-   fuse_flush_mtime(file, true);
+   fuse_flush_mtime(file, ff, true);
 
fuse_release_common(file, FUSE_RELEASE);
 
@@ -724,7 +724,7 @@ int fuse_fsync_common(struct file *file, loff_t start, 
loff_t end,
 
if (!datasync && test_bit(FUSE_I_MTIME_UPDATED,
  _fuse_inode(inode)->state)) {
-   err = fuse_flush_mtime(file, false);
+   err = fuse_flush_mtime(file, isdir ? NULL : ff, false);
if (err)
goto out;
}
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index f704fd17905b..939835f585b1 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1074,7 +1074,7 @@ int fuse_dev_release(struct inode *inode, struct file 
*file);
 
 bool fuse_write_update_size(struct inode *inode, loff_t pos);
 
-int fuse_flush_mtime(struct file *file, bool nofail);
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail);
 
 int fuse_do_setattr(struct inode *inode, struct iattr *attr,
struct file *file);
-- 
2.15.1

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


[Devel] [PATCH rh7] kernel/panic.c: don't dump_stack() in add_taint()

2018-06-04 Thread Andrey Ryabinin
add_taint() callers usually call dump_stack(). The second
dump_stack() only polutes the log.

Signed-off-by: Andrey Ryabinin 
---
 kernel/panic.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 333e36cd1175..6d33011078d2 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -387,12 +387,6 @@ void add_taint(unsigned flag, enum lockdep_ok lockdep_ok)
printk(KERN_WARNING
   "Disabling lock debugging due to kernel taint\n");
 
-   /* Do not confuse people with calltraces on proprietary modules */
-   if (flag != TAINT_PROPRIETARY_MODULE && flag != TAINT_OOT_MODULE &&
-   flag != TAINT_UNSIGNED_MODULE) {
-   printk(KERN_WARNING "Tainting kernel with flag 0x%x\n", flag);
-   dump_stack();
-   }
set_bit(flag, _mask);
 }
 EXPORT_SYMBOL(add_taint);
-- 
2.16.4

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


[Devel] [PATCH rh7] mm/memcg: Remove development debug printk

2018-06-04 Thread Andrey Ryabinin
Remove some debugging printk that accidentally sneaked
in patch "mm/memcg: Don't charge anon pages as cache"

Signed-off-by: Andrey Ryabinin 
---
 mm/memcontrol.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1206a4627610..7905e7c510bf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6962,12 +6962,8 @@ static int __mem_cgroup_try_charge(struct page *page, 
struct mm_struct *mm,
goto out;
}
 
-   if (PageTransHuge(page)) {
+   if (PageTransHuge(page))
nr_pages <<= compound_order(page);
-   if (!PageAnon(page)) {
-   pr_warn_once("page->flags %lx page %p head %p", 
page->flags, page, compound_head(page));
-   }
-   }
 
if (do_swap_account && PageSwapCache(page))
memcg = try_get_mem_cgroup_from_page(page);
-- 
2.16.4

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