Unverified Commit 13ac3d01 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10781 nilfs2: fix kernel bug on rename operation of broken directory

parents 7b55c48f f23e6e9a
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -390,11 +390,39 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr,

struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p)
{
	struct nilfs_dir_entry *de = nilfs_get_page(dir, 0, p);
	struct page *page;
	struct nilfs_dir_entry *de, *next_de;
	size_t limit;
	char *msg;

	de = nilfs_get_page(dir, 0, &page);
	if (IS_ERR(de))
		return NULL;
	return nilfs_next_entry(de);

	limit = nilfs_last_byte(dir, 0);  /* is a multiple of chunk size */
	if (unlikely(!limit || le64_to_cpu(de->inode) != dir->i_ino ||
		     !nilfs_match(1, ".", de))) {
		msg = "missing '.'";
		goto fail;
	}

	next_de = nilfs_next_entry(de);
	/*
	 * If "next_de" has not reached the end of the chunk, there is
	 * at least one more record.  Check whether it matches "..".
	 */
	if (unlikely((char *)next_de == (char *)de + nilfs_chunk_size(dir) ||
		     !nilfs_match(2, "..", next_de))) {
		msg = "missing '..'";
		goto fail;
	}
	*p = page;
	return next_de;

fail:
	nilfs_error(dir->i_sb, "directory #%lu %s", dir->i_ino, msg);
	nilfs_put_page(page);
	return NULL;
}

ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr)