summaryrefslogtreecommitdiff
path: root/fs/ubifs/journal.c
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2016-09-14 23:28:50 +0300
committerRichard Weinberger <richard@nod.at>2016-10-02 23:55:02 +0300
commit9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 (patch)
tree5aacb28779d5befeb285a7334c4ebaa4617d81be /fs/ubifs/journal.c
parent474b93704f32163af4bfa728fddc570eba357353 (diff)
downloadlinux-9e0a1fff8db56eaaebb74b4a3ef65f86811c4798.tar.xz
ubifs: Implement RENAME_WHITEOUT
Adds RENAME_WHITEOUT support to UBIFS, we implement it in the same way as ext4 and xfs do. For an overview of other ways to implement it please refere to commit 7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support"). Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/journal.c')
-rw-r--r--fs/ubifs/journal.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 0b9da5b6e0f9..6b27ddd2c484 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -917,14 +917,15 @@ int ubifs_jnl_delete_inode(struct ubifs_info *c, const struct inode *inode)
* @sync: non-zero if the write-buffer has to be synchronized
*
* This function implements the re-name operation which may involve writing up
- * to 3 inodes and 2 directory entries. It marks the written inodes as clean
+ * to 4 inodes and 2 directory entries. It marks the written inodes as clean
* and returns zero on success. In case of failure, a negative error code is
* returned.
*/
int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
const struct dentry *old_dentry,
const struct inode *new_dir,
- const struct dentry *new_dentry, int sync)
+ const struct dentry *new_dentry,
+ const struct inode *whiteout, int sync)
{
void *p;
union ubifs_key key;
@@ -980,13 +981,19 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
zero_dent_node_unused(dent);
ubifs_prep_grp_node(c, dent, dlen1, 0);
- /* Make deletion dent */
dent2 = (void *)dent + aligned_dlen1;
dent2->ch.node_type = UBIFS_DENT_NODE;
dent_key_init_flash(c, &dent2->key, old_dir->i_ino,
&old_dentry->d_name);
- dent2->inum = 0;
- dent2->type = DT_UNKNOWN;
+
+ if (whiteout) {
+ dent2->inum = cpu_to_le64(whiteout->i_ino);
+ dent2->type = get_dent_type(whiteout->i_mode);
+ } else {
+ /* Make deletion dent */
+ dent2->inum = 0;
+ dent2->type = DT_UNKNOWN;
+ }
dent2->nlen = cpu_to_le16(old_dentry->d_name.len);
memcpy(dent2->name, old_dentry->d_name.name, old_dentry->d_name.len);
dent2->name[old_dentry->d_name.len] = '\0';
@@ -1035,16 +1042,26 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
if (err)
goto out_ro;
- err = ubifs_add_dirt(c, lnum, dlen2);
- if (err)
- goto out_ro;
+ offs += aligned_dlen1;
+ if (whiteout) {
+ dent_key_init(c, &key, old_dir->i_ino, &old_dentry->d_name);
+ err = ubifs_tnc_add_nm(c, &key, lnum, offs, dlen2, &old_dentry->d_name);
+ if (err)
+ goto out_ro;
- dent_key_init(c, &key, old_dir->i_ino, &old_dentry->d_name);
- err = ubifs_tnc_remove_nm(c, &key, &old_dentry->d_name);
- if (err)
- goto out_ro;
+ ubifs_delete_orphan(c, whiteout->i_ino);
+ } else {
+ err = ubifs_add_dirt(c, lnum, dlen2);
+ if (err)
+ goto out_ro;
+
+ dent_key_init(c, &key, old_dir->i_ino, &old_dentry->d_name);
+ err = ubifs_tnc_remove_nm(c, &key, &old_dentry->d_name);
+ if (err)
+ goto out_ro;
+ }
- offs += aligned_dlen1 + aligned_dlen2;
+ offs += aligned_dlen2;
if (new_inode) {
ino_key_init(c, &key, new_inode->i_ino);
err = ubifs_tnc_add(c, &key, lnum, offs, ilen);