[PATCH 4/4] ubifs: Convert do_writepage() to take a folio

Richard Weinberger richard at nod.at
Mon Jun 5 14:37:00 PDT 2023


Matthew,

----- Ursprüngliche Mail -----
> Von: "Matthew Wilcox" <willy at infradead.org>
> -static int do_writepage(struct page *page, int len)
> +static int do_writepage(struct folio *folio, size_t len)
> {
> 	int err = 0, i, blen;
> 	unsigned int block;
> 	void *addr;
> +	size_t offset = 0;
> 	union ubifs_key key;
> -	struct inode *inode = page->mapping->host;
> +	struct inode *inode = folio->mapping->host;
> 	struct ubifs_info *c = inode->i_sb->s_fs_info;
> 
> #ifdef UBIFS_DEBUG
> 	struct ubifs_inode *ui = ubifs_inode(inode);
> 	spin_lock(&ui->ui_lock);
> -	ubifs_assert(c, page->index <= ui->synced_i_size >> PAGE_SHIFT);
> +	ubifs_assert(c, folio->index <= ui->synced_i_size >> PAGE_SHIFT);
> 	spin_unlock(&ui->ui_lock);
> #endif
> 
> -	/* Update radix tree tags */
> -	set_page_writeback(page);
> +	folio_start_writeback(folio);
> 
> -	addr = kmap(page);
> -	block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
> +	addr = kmap_local_folio(folio, offset);
> +	block = folio->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
> 	i = 0;
> -	while (len) {
> -		blen = min_t(int, len, UBIFS_BLOCK_SIZE);
> +	for (;;) {

This change will cause a file system corruption.
If len is zero (it can be) then a zero length data node will be written.
The while(len) made sure that upon zero length nothing is written.

Thanks,
//richard



More information about the linux-mtd mailing list