Commit 8c6bdce0 authored by Chi Zhiling's avatar Chi Zhiling Committed by Namjae Jeon
Browse files

exfat: tweak cluster cache to support zero offset



The current cache mechanism does not support reading clusters starting
from a file offset of zero. This patch enables that feature in
preparation for subsequent reads of contiguous clusters from offset zero.

1. support finding clusters with zero offset.
2. allow clusters with zero offset to be cached.

Signed-off-by: default avatarChi Zhiling <chizhiling@kylinos.cn>
Reviewed-by: default avatarYuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
parent 256694b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ static unsigned int exfat_cache_lookup(struct inode *inode,
	spin_lock(&ei->cache_lru_lock);
	list_for_each_entry(p, &ei->cache_lru, cache_list) {
		/* Find the cache of "fclus" or nearest cache. */
		if (p->fcluster <= fclus && hit->fcluster < p->fcluster) {
		if (p->fcluster <= fclus && hit->fcluster <= p->fcluster) {
			hit = p;
			if (hit->fcluster + hit->nr_contig < fclus) {
				offset = hit->nr_contig;
@@ -259,7 +259,7 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
	if (cluster == 0 || *dclus == EXFAT_EOF_CLUSTER)
		return 0;

	cache_init(&cid, EXFAT_EOF_CLUSTER, EXFAT_EOF_CLUSTER);
	cache_init(&cid, fclus, *dclus);
	exfat_cache_lookup(inode, cluster, &cid, &fclus, dclus);

	if (fclus == cluster)