Re: [RFC PATCH v5] f2fs: support data compression
From: Chao Yu
Date: Sun Dec 22 2019 - 22:37:02 EST
On 2019/12/19 17:53, Geert Uytterhoeven wrote:
> On Mon, Dec 16, 2019 at 7:29 AM Chao Yu <yuchao0@xxxxxxxxxx> wrote:
>> This patch tries to support compression in f2fs.
>
>> +static int f2fs_write_raw_pages(struct compress_ctx *cc,
>> + int *submitted,
>> + struct writeback_control *wbc,
>> + enum iostat_type io_type,
>> + bool compressed)
>> +{
>> + int i, _submitted;
>> + int ret, err = 0;
>> +
>> + for (i = 0; i < cc->cluster_size; i++) {
>> + if (!cc->rpages[i])
>> + continue;
>> +retry_write:
>> + BUG_ON(!PageLocked(cc->rpages[i]));
>> +
>> + ret = f2fs_write_single_data_page(cc->rpages[i], &_submitted,
>> + NULL, NULL, wbc, io_type);
>> + if (ret) {
>> + if (ret == AOP_WRITEPAGE_ACTIVATE) {
>> + unlock_page(cc->rpages[i]);
>> + ret = 0;
>> + } else if (ret == -EAGAIN) {
>> + ret = 0;
>> + cond_resched();
>> + congestion_wait(BLK_RW_ASYNC, HZ/50);
>
> On some platforms, HZ can be less than 50.
> What happens if congestion_wait() is called with a zero timeout?
Thanks for the report, will fix in a separated patch.
Thanks,
>
>> + lock_page(cc->rpages[i]);
>> + clear_page_dirty_for_io(cc->rpages[i]);
>> + goto retry_write;
>> + }
>> + err = ret;
>> + goto out_fail;
>> + }
>> +
>> + *submitted += _submitted;
>> + }
>> + return 0;
>> +
>> +out_fail:
>> + /* TODO: revoke partially updated block addresses */
>> + BUG_ON(compressed);
>> +
>> + for (++i; i < cc->cluster_size; i++) {
>> + if (!cc->rpages[i])
>> + continue;
>> + redirty_page_for_writepage(wbc, cc->rpages[i]);
>> + unlock_page(cc->rpages[i]);
>> + }
>> + return err;
>> +}
>
> Gr{oetje,eeting}s,
>
> Geert
>