> -----Original Message----- > From: Namjae Jeon <linkinjeon@xxxxxxxxxx> > Sent: Tuesday, December 5, 2023 11:30 AM > To: Mo, Yuezhang <Yuezhang.Mo@xxxxxxxx> > Cc: sj1557.seo@xxxxxxxxxxx; linux-fsdevel@xxxxxxxxxxxxxxx; Wu, Andy > <Andy.Wu@xxxxxxxx>; Aoyama, Wataru (SGC) <Wataru.Aoyama@xxxxxxxx>; > cpgs@xxxxxxxxxxx > Subject: Re: [PATCH v5 1/2] exfat: change to get file size from DataLength > > > +static int exfat_file_zeroed_range(struct file *file, loff_t start, loff_t > > end) > > +{ > > + int err; > > + struct inode *inode = file_inode(file); > > + struct exfat_inode_info *ei = EXFAT_I(inode); > > + struct address_space *mapping = inode->i_mapping; > > + const struct address_space_operations *ops = mapping->a_ops; > > + > > + while (start < end) { > > + u32 zerofrom, len; > > + struct page *page = NULL; > > + > > + zerofrom = start & (PAGE_SIZE - 1); > > + len = PAGE_SIZE - zerofrom; > > + if (start + len > end) > > + len = end - start; > > + > > + err = ops->write_begin(file, mapping, start, len, &page, NULL); > Is there any reason why you don't use block_write_begin and > generic_write_end() ? > > Thanks. If use block_write_begin(), we need to remove 'static' from exfat_get_block(), use ops->write_begin() and ops->write_end() makes the function more generic, maybe we can rename this function to generic_write_zero() and move it to fs/buffer.c. And ei->valid_size had updated in ops->write_end(), it is unneeded to update in this function. > > + if (err) > > + goto out; > > + > > + zero_user_segment(page, zerofrom, zerofrom + len); > > + > > + err = ops->write_end(file, mapping, start, len, len, page, NULL); > > + if (err < 0) > > + goto out; > > + start += len; > > + > > + balance_dirty_pages_ratelimited(mapping); > > + cond_resched(); > > + } > > + > > + ei->valid_size = end; > > + mark_inode_dirty(inode); > > + > > +out: > > + return err; > > +}