From 5512e67fd99925c715017b59813b0a914216e032 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Fri, 7 Nov 2008 16:50:16 -0500 Subject: [PATCH] Unionfs: handle partial copyup errors gracefully Don't leave any dentries behind if copying up the inode (or setting its permission, i.e., using TOMOYO) failed. CC: Tetsuo Handa Signed-off-by: Erez Zadok --- fs/unionfs/copyup.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c index 3e0a6ab5a24..7613d7bd7c5 100644 --- a/fs/unionfs/copyup.c +++ b/fs/unionfs/copyup.c @@ -527,8 +527,17 @@ out_free: dput(old_lower_dentry); kfree(symbuf); - if (err) + if (err) { + /* + * if directory creation succeeded, but inode copyup failed, + * then purge new dentries. + */ + if (dbstart(dentry) < old_bstart && + ibstart(dentry->d_inode) > dbstart(dentry)) + __clear(dentry, NULL, old_bstart, old_bend, + unionfs_lower_dentry(dentry), dbstart(dentry)); goto out; + } if (!S_ISDIR(dentry->d_inode->i_mode)) { unionfs_postcopyup_release(dentry); if (!unionfs_lower_inode(dentry->d_inode)) { -- 2.34.1