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

Commit 077e073e authored by Fabian Frederick's avatar Fabian Frederick Committed by Al Viro
Browse files

fs/affs: bugfix: enable writes on OFS disks

We called unconditionally affs_bread_ino() with create 0 resulting in
"error (device ...): get_block(): strange block request 0"
when trying to write on AFFS OFS format.

This patch adds create parameter to that function.
0 for affs_readpage_ofs()
1 for affs_write_begin_ofs()

Bug was found here:
https://bugzilla.kernel.org/show_bug.cgi?id=114961



Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a9d6cfb7
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -499,7 +499,7 @@ affs_getemptyblk_ino(struct inode *inode, int block)
}
}


static int
static int
affs_do_readpage_ofs(struct page *page, unsigned to)
affs_do_readpage_ofs(struct page *page, unsigned to, int create)
{
{
	struct inode *inode = page->mapping->host;
	struct inode *inode = page->mapping->host;
	struct super_block *sb = inode->i_sb;
	struct super_block *sb = inode->i_sb;
@@ -518,7 +518,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to)
	boff = tmp % bsize;
	boff = tmp % bsize;


	while (pos < to) {
	while (pos < to) {
		bh = affs_bread_ino(inode, bidx, 0);
		bh = affs_bread_ino(inode, bidx, create);
		if (IS_ERR(bh))
		if (IS_ERR(bh))
			return PTR_ERR(bh);
			return PTR_ERR(bh);
		tmp = min(bsize - boff, to - pos);
		tmp = min(bsize - boff, to - pos);
@@ -620,7 +620,7 @@ affs_readpage_ofs(struct file *file, struct page *page)
		memset(page_address(page) + to, 0, PAGE_SIZE - to);
		memset(page_address(page) + to, 0, PAGE_SIZE - to);
	}
	}


	err = affs_do_readpage_ofs(page, to);
	err = affs_do_readpage_ofs(page, to, 0);
	if (!err)
	if (!err)
		SetPageUptodate(page);
		SetPageUptodate(page);
	unlock_page(page);
	unlock_page(page);
@@ -657,7 +657,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping
		return 0;
		return 0;


	/* XXX: inefficient but safe in the face of short writes */
	/* XXX: inefficient but safe in the face of short writes */
	err = affs_do_readpage_ofs(page, PAGE_SIZE);
	err = affs_do_readpage_ofs(page, PAGE_SIZE, 1);
	if (err) {
	if (err) {
		unlock_page(page);
		unlock_page(page);
		put_page(page);
		put_page(page);