From: OGAWA Hirofumi Subject: Re: [PATCH v5] fat: Batched discard support for fat Date: Mon, 28 Mar 2011 15:21:05 +0900 Message-ID: <874o6n6a0e.fsf@devron.myhome.or.jp> References: <20110318020433.GA27263@july> <877hbkpo7v.fsf@devron.myhome.or.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Lukas Czerner To: Kyungmin Park Return-path: Received: from mail.parknet.co.jp ([210.171.160.6]:44855 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259Ab1C1GVK (ORCPT ); Mon, 28 Mar 2011 02:21:10 -0400 In-Reply-To: (Kyungmin Park's message of "Mon, 28 Mar 2011 14:57:22 +0900") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Kyungmin Park writes: >>> + =A0 =A0 start =3D range->start >> sb->s_blocksize_bits; >>> + =A0 =A0 start =3D start / sbi->sec_per_clus; >> >> start is round-down, I think it's strange interface. E.g. user speci= fied >> the range as "start=3D10 len=3D1024". So the range should be 10-1034= , >> i.e. (assume cluster-size is 512) 512-1024, right? > > I don't know what's the correct way? If you're right. it's better to = round-up. > If cluster-size is 32KiB and start sector is in the middle of cluster= , > then which is better. round-down or round-up? It depends on the design of this interface though, I bet it's round-up, and should use same way with other FSes. >>> + =A0 =A0 minlen =3D range->minlen >> sb->s_blocksize_bits; >>> + =A0 =A0 minlen =3D minlen / sbi->sec_per_clus; >>> + =A0 =A0 trimmed =3D 0; >>> + =A0 =A0 count =3D 0; >>> + =A0 =A0 err =3D -EINVAL; >>> + >>> + =A0 =A0 lock_fat(sbi); >>> + =A0 =A0 if (sbi->free_clusters !=3D -1 && sbi->free_clus_valid) >>> + =A0 =A0 =A0 =A0 =A0 =A0 goto out; >> >> free clusters count validation doesn't matter here. If you want to c= heck >> free cluster count, you should check free_clusters=3D=3D0 or not (af= ter >> validation). > > I borrowed it from "fat_count_free_clusters()". anyway fill fix it. Yes. fat_count_free_clusters() needs to check free_clusters value, because it updates free_clusters value. If it's uptodate, does nothing. >>> + =A0 =A0 if (start < FAT_START_ENT) >>> + =A0 =A0 =A0 =A0 =A0 =A0 start =3D FAT_START_ENT; >> >> Valid data cluster is 2 - max_cluster, but it should be mapped to 0 = - >> (max_cluster - FAT_START_ENT). Otherwise this interface's abstractio= n is >> useless, right? > > user program don't know the filesystem internals. The same program is > used for ext4 and fat. so it should be handled at filesystem. Yes. It's what I'm saying. If user wants to trim 0-2 then user will specify 0-2, but this trims only 2. It's not right. >>> + =A0 =A0 fatent_set_entry(&fatent, start); >>> + >>> + =A0 =A0 while (count < sbi->max_cluster) { >>> + =A0 =A0 =A0 =A0 =A0 =A0 if (fatent.entry >=3D sbi->max_cluster) >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fatent.entry =3D FAT_STAR= T_ENT; >> >> Why do we cyclic this? > If the start is middle and len is the whole disk size, then check the > all clusters. Strange design. If user wants to trim between middle and end, user have to know length from middle correctly? Ext4 really does it? Thanks. --=20 OGAWA Hirofumi -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html