Re: [RFC PATCH 7/9] jfs: Read quota through the page cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>  static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
> +			      size_t len, loff_t pos)
>  {
>  	struct inode *inode = sb_dqopt(sb)->files[type];
> +	struct address_space *mapping = inode->i_mapping;
>  	size_t toread;
> +	pgoff_t index;
>  	loff_t i_size = i_size_read(inode);
>  
> +	if (pos > i_size)
>  		return 0;
> +	if (pos + len > i_size)
> +		len = i_size - pos;
>  	toread = len;
> +	index = pos / PAGE_SIZE;
> +
>  	while (toread > 0) {
> +		struct folio *folio = read_mapping_folio(mapping, index, NULL);
> +		size_t tocopy = PAGE_SIZE - offset_in_page(pos);
> +		void *src;
> +
> +		if (IS_ERR(folio))
> +			return PTR_ERR(folio);
> +
> +		src = kmap_local_folio(folio, offset_in_folio(folio, pos));
> +		memcpy(data, src, tocopy);
> +		kunmap_local(src);

It would be great to have a memcpy_from_folio like the existing
memcpy_from_page for this.

> +		folio_put(folio);
>  
>  		toread -= tocopy;
>  		data += tocopy;
> +		pos += tocopy;
> +		index++;
>  	}
>  	return len;

And this whole helper is generic now.  It might be worth to move it
into fs/quota/dquot.c as generic_quota_read.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux