Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82985248 authored by Wengang Wang's avatar Wengang Wang Committed by Joel Becker
Browse files

ocfs2: make direntry invalid when deleting it



When we deleting a direntry from a directory, if it's the first in a block we
invalid it by setting inode to 0; otherwise, we merge the deleted one to the
prior and contiguous direntry. And we don't truncate directories.

There is a problem for the later case since inode is not set to 0.
This problem happens when the caller passes a file position as parameter to
ocfs2_dir_foreach_blk(). If the position happens to point to a stale(not
the first, deleted in betweens of ocfs2_dir_foreach_blk()s) direntry, we are
not able to recognize its staleness. So that we treat it as a live one wrongly.

The fix is to set inode to 0 in both cases indicating the direntry is stale.
This won't introduce additional IOs.

Signed-off-by: default avatarWengang Wang <wen.gang.wang@oracle.com>
Signed-off-by: default avatarJoel Becker <jlbec@evilplan.org>
parent fc9f8994
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -1184,7 +1184,6 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
			if (pde)
			if (pde)
				le16_add_cpu(&pde->rec_len,
				le16_add_cpu(&pde->rec_len,
						le16_to_cpu(de->rec_len));
						le16_to_cpu(de->rec_len));
			else
			de->inode = 0;
			de->inode = 0;
			dir->i_version++;
			dir->i_version++;
			ocfs2_journal_dirty(handle, bh);
			ocfs2_journal_dirty(handle, bh);