currently threads do

old_flags = current->flags;
current->flags |= ploop flags;
...
current->flags = old_flags;

this can break process flags

To fix this use  current_restore_flags(..) macro which only removes
our flags and it preserves any other flags.

https://virtuozzo.atlassian.net/browse/VSTOR-98626
Signed-off-by: Alexander Atanasov <alexander.atana...@virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index c6c46b49bccf..7efbaedd69e0 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -2150,6 +2150,7 @@ void ploop_resubmit_enospc_pios(struct ploop *ploop)
                ploop_submit_embedded_pios(ploop, 
llist_reverse_order(enospc_pending));
 }
 
+#define PLOOP_PFLAGS (PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO)
 void do_ploop_run_work(struct ploop *ploop)
 {
        LLIST_HEAD(deferred_pios);
@@ -2163,7 +2164,7 @@ void do_ploop_run_work(struct ploop *ploop)
        int npios;
        int force_md_update;
 
-       current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+       current->flags |= PLOOP_PFLAGS;
 
        if (ploop->submit_enospc) {
                ploop->submit_enospc = false;
@@ -2201,10 +2202,10 @@ void do_ploop_run_work(struct ploop *ploop)
         * put stick in the wheel - wait for all pios to be executed before 
doing metadata
         * we could gain a bit more iops if we can skip this wait but for now 
we can not
         */
-       current->flags = old_flags;
+       current_restore_flags(old_flags, PLOOP_PFLAGS);
        wait_event_interruptible(ploop->dispatcher_wq_data,
                                 (!ploop_runners_have_pending(ploop)));
-       current->flags |= PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+       current->flags |= PLOOP_PFLAGS;
 
        /* if we have a flush we must sync md data too */
        force_md_update = !!llflush_pios | ploop->force_md_writeback;
@@ -2212,25 +2213,25 @@ void do_ploop_run_work(struct ploop *ploop)
 
        if (npios) {
                /* wait for metadata writeback to complete */
-               current->flags = old_flags;
+               current_restore_flags(old_flags, PLOOP_PFLAGS);
                /* First wait all pios to be processed */
                wait_event_interruptible(ploop->dispatcher_wq_data,
                                         (!ploop_runners_have_pending(ploop)));
-               current->flags |= 
PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+               current->flags |= PLOOP_PFLAGS;
        }
        if (llflush_pios || npios) {
                /* Now process fsync pios after we have done all other */
                npios = process_ploop_fsync_work(ploop, llflush_pios);
                /* Since dispatcher is single thread no other work can be 
queued */
                if (npios) {
-                       current->flags = old_flags;
+                       current_restore_flags(old_flags, PLOOP_PFLAGS);
                        wait_event_interruptible(ploop->dispatcher_wq_fsync,
                                        
!atomic_read(&ploop->kt_worker->fsync_pios));
-                       current->flags |= 
PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+                       current->flags |= PLOOP_PFLAGS;
                }
        }
 
-       current->flags = old_flags;
+       current_restore_flags(old_flags, PLOOP_PFLAGS);
 }
 
 void do_ploop_work(struct work_struct *ws)
@@ -2253,7 +2254,7 @@ int ploop_allocator(void *data)
                if (ploop->prealloc_size) {
                        __set_current_state(TASK_RUNNING);
                        file = ploop_top_delta(ploop)->file;
-                       current->flags |= 
PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+                       current->flags |= PLOOP_PFLAGS;
                        ret = ploop_preallocate_cluster(ploop, file);
                        if (ret) {
                                /*
@@ -2266,7 +2267,7 @@ int ploop_allocator(void *data)
                                               ploop_device_name(ploop), ret);
                        }
                        wake_up_interruptible(&ploop->dispatcher_wq_prealloc);
-                       current->flags = old_flags;
+                       current_restore_flags(old_flags, PLOOP_PFLAGS);
                }
                if (kthread_should_stop()) {
                        __set_current_state(TASK_RUNNING);
@@ -2291,7 +2292,7 @@ int ploop_pio_runner(void *data)
        int did_process_fsync = 0;
 
        for (;;) {
-               current->flags = old_flags;
+               current_restore_flags(old_flags, PLOOP_PFLAGS);
                set_current_state(TASK_INTERRUPTIBLE);
 
 check_for_more:
@@ -2314,8 +2315,7 @@ int ploop_pio_runner(void *data)
                        continue;
                }
                __set_current_state(TASK_RUNNING);
-               old_flags = current->flags;
-               current->flags |= 
PF_IO_THREAD|PF_LOCAL_THROTTLE|PF_MEMALLOC_NOIO;
+               current->flags |= PLOOP_PFLAGS;
 
                llist_for_each_safe(pos, t, llwork) {
                        pio = list_entry((struct list_head *)pos, typeof(*pio), 
list);
-- 
2.43.0

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

Reply via email to