[Devel] [PATCH RHEL7 COMMIT] ub/fs: access dirtied_ub under rcu lock in __writeback_single_inode

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 16 08:14:09 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.13
------>
commit 73997df7ea94fc95b7b0db70fbacc1c791a89acb
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Tue Jun 16 19:14:09 2015 +0400

    ub/fs: access dirtied_ub under rcu lock in __writeback_single_inode
    
    Related to patchset:
    
    https://jira.sw.ru/browse/PSBM-34007
    
    Vladimir Davydov (7):
      ioprio: move IOPRIO_WHO_UBC handling out of rcu section
      ub: zap ub_{init,fini}_ioprio
      ub: export ub_get_{mem,blkio}_css
      ub: ressurrect ioprio_set IOPRIO_WHO_UBC
      ub: ressurrect iostat and ioprio reporting
      ub: account writeback io
      ub: do not include block/blk-cgroup.h from io_prio.c
    
    This patch description:
    
    Unlike RH6, we are not holding any locks in __writeback_single_inode, so
    we must dereference dirtied_ub carefully, under rcu read lock.
    
    Also, if dirtied_ub == NULL, account writeback to ub0 as suggested by
    dmonakhov at .
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/fs-writeback.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 8362cc9..b2f77f4 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -491,16 +491,18 @@ __do_writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
 static int
 __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
 {
-	struct user_beancounter *ub = inode->i_mapping->dirtied_ub;
+	struct user_beancounter *ub;
 	int ret;
 
-	if (likely(get_exec_ub() == ub || !ub))
-		return __do_writeback_single_inode(inode, wbc);
+	rcu_read_lock();
+	ub = rcu_dereference(inode->i_mapping->dirtied_ub);
+	if (!ub || !get_beancounter_rcu(ub))
+		ub = get_beancounter(get_ub0());
+	rcu_read_unlock();
 
-	ub = get_beancounter_rcu(ub) ? set_exec_ub(ub) : NULL;
+	ub = set_exec_ub(ub);
 	ret = __do_writeback_single_inode(inode, wbc);
-	if (ub)
-		put_beancounter(set_exec_ub(ub));
+	put_beancounter(set_exec_ub(ub));
 
 	return ret;
 }



More information about the Devel mailing list