From nobody Fri Oct 3 20:22:32 2025 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 494912E11CC for ; Sun, 15 Jun 2025 14:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749998567; cv=none; b=ad2vE0Nz3iJF5aWif1T+55YgPBg2TOvu5FYVF8ONXINzefOzNBte2n10usd7tNLGrOKlBoQO6Psdu+K/vkuR86Th/6+xHrmPtWByl1Bpl55F3owqzR43NgQMurVBSmnut/VwUeg/uPUvCKkf6pDjXp59ZgYKW2K8yNRRKmacoKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749998567; c=relaxed/simple; bh=h+2Vul6P6VLZ7sx+lkBAUQJ1X2LZKStD+mU6cdUi06E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cH/Gp/tRDJPaezWAmioUTajpeD7t07DBcw8J/NUo8soMgJ8Wp1mfKpkvnANW2L36OXT1w2E14AC7BAvIq4KqylAzrGC3eZmUnEfUVrhvRLL9dNdvOQ093+EXSC8oKSMq3LiEwjjrntOm0Sj4ER//tJvmPYV8XCB8jP7ngc7nLVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--chullee.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=I7m327UY; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--chullee.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="I7m327UY" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-747d143117eso2933024b3a.3 for ; Sun, 15 Jun 2025 07:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1749998563; x=1750603363; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1FP1lr7F8Nfg636WYePAdThDfLRPJuPcNEgEc6zg7pA=; b=I7m327UY+LZaWeS4fGjSSdpcXohGH21ojE089Vu4fzcl8Vb9bqSIskY0z0htrw9NkF 5IVcCp4zjEmadmep6CHXWZU7tPVu4fJdgwq19K4FdUXBQvLe9WQAEfMjhh3tH/EK70mG 9vlqTORG8X9kToG1CPWL1fKXoF66S+5GaR0h3+ShJ8+b6EL2itOG7Ywz6xvX/P21Jl21 U+v5g54iBZuKWxbAMEUVilVR/ecaSywp2sPCrHlFBqFa9T5hH8L22Tux5us/1vox/YmO lUEhk+EcUolrhHrXBWBS3wUlNh5RTXQwmk0YZ2vZgNXE/6OSmKHLvILcZu81ZA9M2S3E WJxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749998563; x=1750603363; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1FP1lr7F8Nfg636WYePAdThDfLRPJuPcNEgEc6zg7pA=; b=AAId80n9EwehgtuH3pwCcqlBJ6PdI41l1LOXAs2MzP80Crc49Sb5msklyb0rgtbSb4 3IRVoSYUuEsvv95PgZBKHCYHX9Jsa6lK2kYlDFZ4LJ9KiRpHIqNOYGrF+MIDZlSlRcYL JyFgSnRNIIzor4ysXrtXx8UlDAVxAMwSdDPvJZdQ0DJVSvsExLS2AdT1yXXDYq/GdFGg +Rnsf8hT7Nz2vRfw05Lw16sCQ9hnuFG7ekD03KWmU35G7sAv0AJQCMMp823kk5pzQmr6 DAGh2xp47s69JIPSCk7PgDdVHzG9u2k+1F9TE9A7WiRb3mlWBKyeaigwHjD7+soC+DAL Bl5A== X-Forwarded-Encrypted: i=1; AJvYcCWXWOEnr4tZghMKaf2GHV8sdAsimEOdrVEikhn9Xd2803Mgv+mmqBEiiU9lMfJ3HPU0xBQtr2MqPWU1gmg=@vger.kernel.org X-Gm-Message-State: AOJu0YzWj+IQxNIkdMe+g4xC50Y5Fj7MWOtKjSSXt0IgA77FMEJ1bRgi rOOPDPtnMR0xn5IuPcDK7vJl+AMTbqj2Hh3ULEzEdHaSlEpgDlyi7HSUqF+kfnbHN989AX6eDDW QbUV0S6Turw== X-Google-Smtp-Source: AGHT+IHzP7AUKodFfcUQEoSRgZ1jidwGwp2ewdXVIHXUuxsVHg64QnNNcwNp4YCCkeylIh30mSg5nKzfGvto X-Received: from pfjc11.prod.google.com ([2002:a05:6a00:8b:b0:746:2e25:5c93]) (user=chullee job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:10c9:b0:748:2d1d:f7b3 with SMTP id d2e1a72fcca58-7489d008a33mr7049901b3a.22.1749998563600; Sun, 15 Jun 2025 07:42:43 -0700 (PDT) Date: Sun, 15 Jun 2025 07:42:34 -0700 In-Reply-To: <20250615144235.1836469-1-chullee@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250615144235.1836469-1-chullee@google.com> X-Mailer: git-send-email 2.50.0.rc1.591.g9c95f17f64-goog Message-ID: <20250615144235.1836469-2-chullee@google.com> Subject: [PATCH v2 1/2] f2fs: Apply bio flags to direct I/O From: Daniel Lee To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Daniel Lee Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bio flags like REQ_PRIO, REQ_META, and REQ_FUA, determined by f2fs_io_flags(), were not being applied to direct I/O (DIO) writes. This meant that DIO writes would not respect filesystem-level hints (for REQ_META/FUA) or inode-level hints (like F2FS_IOPRIO_WRITE). This patch refactors f2fs_io_flags() to use a direct inode pointer instead of deriving it from a page. The function is then called from the DIO write path, ensuring that bio flags are handled consistently for both buffered and DIO writes. Signed-off-by: Daniel Lee --- fs/f2fs/data.c | 10 +++++----- fs/f2fs/f2fs.h | 1 + fs/f2fs/file.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 31e892842625..71dde494b892 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -416,10 +416,9 @@ int f2fs_target_device_index(struct f2fs_sb_info *sbi,= block_t blkaddr) return 0; } =20 -static blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio) +blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio, struct inode *inode) { unsigned int temp_mask =3D GENMASK(NR_TEMP_TYPE - 1, 0); - struct folio *fio_folio =3D page_folio(fio->page); unsigned int fua_flag, meta_flag, io_flag; blk_opf_t op_flags =3D 0; =20 @@ -446,8 +445,8 @@ static blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio) if (BIT(fio->temp) & fua_flag) op_flags |=3D REQ_FUA; =20 - if (fio->type =3D=3D DATA && - F2FS_I(fio_folio->mapping->host)->ioprio_hint =3D=3D F2FS_IOPRIO_WRIT= E) + if (inode && fio->type =3D=3D DATA && + F2FS_I(inode)->ioprio_hint =3D=3D F2FS_IOPRIO_WRITE) op_flags |=3D REQ_PRIO; =20 return op_flags; @@ -459,10 +458,11 @@ static struct bio *__bio_alloc(struct f2fs_io_info *f= io, int npages) struct block_device *bdev; sector_t sector; struct bio *bio; + struct inode *inode =3D fio->page ? fio->page->mapping->host : NULL; =20 bdev =3D f2fs_target_device(sbi, fio->new_blkaddr, §or); bio =3D bio_alloc_bioset(bdev, npages, - fio->op | fio->op_flags | f2fs_io_flags(fio), + fio->op | fio->op_flags | f2fs_io_flags(fio, inode), GFP_NOIO, &f2fs_bioset); bio->bi_iter.bi_sector =3D sector; if (is_read_io(fio->op)) { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 9333a22b9a01..3e02687c1b58 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3972,6 +3972,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio); struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi, block_t blk_addr, sector_t *sector); int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr); +blk_opf_t f2fs_io_flags(struct f2fs_io_info *fio, struct inode *inode); void f2fs_set_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr); void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr); int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 696131e655ed..3eb40d7bf602 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -5015,6 +5015,17 @@ static void f2fs_dio_write_submit_io(const struct io= map_iter *iter, enum log_type type =3D f2fs_rw_hint_to_seg_type(sbi, inode->i_write_hint); enum temp_type temp =3D f2fs_get_segment_temp(sbi, type); =20 + /* if fadvise set to hot, override the temperature */ + struct f2fs_io_info fio =3D { + .sbi =3D sbi, + .type =3D DATA, + .op =3D REQ_OP_WRITE, + .temp =3D file_is_hot(inode) ? HOT : temp, + .op_flags =3D bio->bi_opf, + .page =3D NULL, + }; + bio->bi_opf |=3D f2fs_io_flags(&fio, inode); + bio->bi_write_hint =3D f2fs_io_type_to_rw_hint(sbi, DATA, temp); submit_bio(bio); } --=20 2.50.0.rc1.591.g9c95f17f64-goog From nobody Fri Oct 3 20:22:32 2025 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ED62155326 for ; Sun, 15 Jun 2025 14:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749998568; cv=none; b=tsbr97+UCJ9u5ejHMbuiAF6oofUjprjlpZLUdlSaSUK8V/b5ccoFHJI6HW/KYwoqSdesGu7l9OY2D6FkWgZ8gUTwqvme1jOjFQXCaz9ORB5Felg7ZA36B39OWr7HOnER473UMzpf9JGV5jQuVd/8sGz5pKaCqAToBK3obG3Z6EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749998568; c=relaxed/simple; bh=Jng+g8ztoIetD9iBZDKFygVqjhAs2D0eICPof3vwvCk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WhnTQ41+rpYWSMcf/hibBi+Jt0KTIz43T3PcRaI069KPNK88mJb11AGDBAljf/emZuN07fI1d7/ovTAVIUXA9QSUX19eT+IMLgbPHuHQtly229JwdDYh6f3P2ivD9gFKPDHWLGIwu5XiP37Wk5FwU5D/y9MzhVLazNDWCXWJF+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--chullee.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3wF0Ptyn; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--chullee.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3wF0Ptyn" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b2c36d3f884so2417094a12.2 for ; Sun, 15 Jun 2025 07:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1749998566; x=1750603366; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BYrmpF/Q6roI8L6nTRyQRvZjOfZjRGnDoVWGywhO7no=; b=3wF0PtynMTBdlMhI5E8a4vVcQxiPkLwhGcE8oGBpPAOj/OtWOfpL9XFYuuZAa4DnK2 En3Yd9GI2InTsF0qq5iLouOSTdpQ3ynblMoTwv0SCNMesPfMRAXVc07Hn8+CFYjCKzvT b0RKlNBpg3TC0XwhpkVgiIFzHJS8h+0id21EcNC9Qyy1Zc/J4DatmkJ0jS1ybrG1U8QF ANzhLT5TwLP89k2RlcE1lSXntqiitD3F5+NDP9yq/Rhtxe4uZ34URW4imXpOCLt6MMR9 HFOzSxCMIvXrAjsnMPiDDIvqW16FOTe+ogf+iJpK135WS2V2fou9LcP817gGFh/E1VXn 8d3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749998566; x=1750603366; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BYrmpF/Q6roI8L6nTRyQRvZjOfZjRGnDoVWGywhO7no=; b=XMsDtH62HodYPuKRTqqIX4EmHVqp3RABn1NcD8zon4xrh7DiyGw//vu/43KxQPD3IG lwW7+PAqTMvKvy/QBwbr0oPtGZIOZZlhs+TY6Yx/YCZt23ukQ/E1CJ/qCOA0JBW3Xxnf VzBNJvmol0N+KVJKFtJaNUQZlUJR3xDFcrhhgfX5jurzyk7uuR5LebUU7wQwqcfuYylG Nbxnsnu0glyocpTNjmnBz22oLfQSUavaNlFDitI0kQC4yb8MGnfHip6dLbdbSkSljUrR 2AmkMB0ymuAnKC5mEoU9lpBtr+qTh4npsKLGy5XTEq9l0XF77AeupfgIoFEVKrLbRPV2 btEA== X-Forwarded-Encrypted: i=1; AJvYcCX5WGwZgG9CyaZgpxq0M1b8ag7MROgHbXxmq4Cch95arys88anp/UHOIKoERGCSN3KbcxlkuTf1RMlnwaY=@vger.kernel.org X-Gm-Message-State: AOJu0YwmlVUX3sm1OpPeSBTH8RmfRFz8SdrT9Z4zaeEWeXtervx2uvDq 8PnNR3aOAN/osrhEju+tXvlYbf7jFhMV4k8gYlHz1d+4KnML8BJjyjVHO5YvLYD9LhyFhGfgVr2 AcKW229Tm1Q== X-Google-Smtp-Source: AGHT+IFt++TjvatBBJIzcufhdDysgmNuitmX6MQe3gnXirWSE2I2TvPCnUxSEDsAPYWrjK1ujziE4tc4e6Uw X-Received: from pfkq14.prod.google.com ([2002:a05:6a00:84e:b0:747:a8ac:ca05]) (user=chullee job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:9006:b0:21f:545e:84f0 with SMTP id adf61e73a8af0-21fbd5e0e49mr9384276637.40.1749998566653; Sun, 15 Jun 2025 07:42:46 -0700 (PDT) Date: Sun, 15 Jun 2025 07:42:35 -0700 In-Reply-To: <20250615144235.1836469-1-chullee@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250615144235.1836469-1-chullee@google.com> X-Mailer: git-send-email 2.50.0.rc1.591.g9c95f17f64-goog Message-ID: <20250615144235.1836469-3-chullee@google.com> Subject: [PATCH v2 2/2] f2fs: use ioprio hint for hot and pinned files From: Daniel Lee To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Daniel Lee Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Apply the `ioprio_hint` to set `F2FS_IOPRIO_WRITE` priority on files identified as "hot" at creation and on files that are pinned via ioctl. Signed-off-by: Daniel Lee --- fs/f2fs/f2fs.h | 19 +++++++++++++++++++ fs/f2fs/file.c | 3 +++ fs/f2fs/namei.c | 11 +++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3e02687c1b58..0c4f52892ff7 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3440,6 +3440,25 @@ static inline void set_file(struct inode *inode, int= type) f2fs_mark_inode_dirty_sync(inode, true); } =20 +static inline int get_ioprio(struct inode *inode) +{ + return F2FS_I(inode)->ioprio_hint; +} + +static inline void set_ioprio(struct inode *inode, int level) +{ + if (get_ioprio(inode) =3D=3D level) + return; + F2FS_I(inode)->ioprio_hint =3D level; +} + +static inline void clear_ioprio(struct inode *inode) +{ + if (get_ioprio(inode) =3D=3D 0) + return; + F2FS_I(inode)->ioprio_hint =3D 0; +} + static inline void clear_file(struct inode *inode, int type) { if (!is_file(inode, type)) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 3eb40d7bf602..a18fb7f3d019 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3496,6 +3496,7 @@ static int f2fs_ioc_set_pin_file(struct file *filp, u= nsigned long arg) =20 if (!pin) { clear_inode_flag(inode, FI_PIN_FILE); + clear_ioprio(inode); f2fs_i_gc_failures_write(inode, 0); goto done; } else if (f2fs_is_pinned_file(inode)) { @@ -3529,6 +3530,8 @@ static int f2fs_ioc_set_pin_file(struct file *filp, u= nsigned long arg) } =20 set_inode_flag(inode, FI_PIN_FILE); + file_set_hot(inode); + set_ioprio(inode, F2FS_IOPRIO_WRITE); ret =3D F2FS_I(inode)->i_gc_failures; done: f2fs_update_time(sbi, REQ_TIME); diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 07e333ee21b7..0f96a0b86c40 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -191,9 +191,10 @@ static void set_compress_new_inode(struct f2fs_sb_info= *sbi, struct inode *dir, } =20 /* - * Set file's temperature for hot/cold data separation + * Set file's temperature (for hot/cold data separation) and + * I/O priority, based on filename extension */ -static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *i= node, +static void set_file_temp_prio(struct f2fs_sb_info *sbi, struct inode *ino= de, const unsigned char *name) { __u8 (*extlist)[F2FS_EXTENSION_LEN] =3D sbi->raw_super->extension_list; @@ -212,8 +213,10 @@ static void set_file_temperature(struct f2fs_sb_info *= sbi, struct inode *inode, =20 if (i < cold_count) file_set_cold(inode); - else + else { file_set_hot(inode); + set_ioprio(inode, F2FS_IOPRIO_WRITE); + } } =20 static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, @@ -317,7 +320,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *i= dmap, set_inode_flag(inode, FI_INLINE_DATA); =20 if (name && !test_opt(sbi, DISABLE_EXT_IDENTIFY)) - set_file_temperature(sbi, inode, name); + set_file_temp_prio(sbi, inode, name); =20 stat_inc_inline_xattr(inode); stat_inc_inline_inode(inode); --=20 2.50.0.rc1.591.g9c95f17f64-goog