All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: khiremat@redhat.com
Cc: idryomov@gmail.com, pdonnell@redhat.com, vshankar@redhat.com,
	xiubli@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH v1 1/1] ceph: Fix incorrect statfs report for small quota
Date: Tue, 09 Nov 2021 12:02:12 -0500	[thread overview]
Message-ID: <930ef6492acab416c5a4fd43ada6b16daec4048e.camel@kernel.org> (raw)
In-Reply-To: <20211109091041.121750-2-khiremat@redhat.com>

On Tue, 2021-11-09 at 14:40 +0530, khiremat@redhat.com wrote:
> From: Kotresh HR <khiremat@redhat.com>
> 
> Problem:
> The statfs reports incorrect free/available space
> for quota less then CEPH_BLOCK size (4M).
> 
> Solution:
> For quotas less than CEPH_BLOCK size, it is
> decided to go with binary use/free of full block.
> For quota size less than CEPH_BLOCK size, report
> the total=used=CEPH_BLOCK,free=0 when quota is
> full and total=free=CEPH_BLOCK, used=0 otherwise.
> 
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
> ---
>  fs/ceph/quota.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
> index 620c691af40e..d49ba82d08bf 100644
> --- a/fs/ceph/quota.c
> +++ b/fs/ceph/quota.c
> @@ -505,6 +505,22 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)
>  			buf->f_bfree = free;
>  			buf->f_bavail = free;
>  			is_updated = true;
> +		} else if (ci->i_max_bytes) {
> +			/* For quota size less than CEPH_BLOCK size, report
> +			 * the total=used=CEPH_BLOCK,free=0 when quota is full and
> +			 * total=free=CEPH_BLOCK, used=0 otherwise  */
> +			total = ci->i_max_bytes;
> +			used = ci->i_rbytes;
> +
> +			buf->f_blocks = 1;
> +			if (total > used) {
> +				buf->f_bfree = 1;
> +				buf->f_bavail = 1;
> +			} else {
> +				buf->f_bfree = 0;
> +				buf->f_bavail = 0;
> +			}
> +			is_updated = true;
>  		}
>  		iput(in);
>  	}

Technically this is (sort of) correct, but the lack of granularity makes
this reporting somewhat useless.

Honestly, I'd rather see this switch to reporting a smaller blocksize
when you get down to <4M max_bytes. If people are setting quotas that
are that small, then they probably would like to be able to look at "df"
and see if they're approaching their quota. This doesn't give them that
capability.

Instead, could we just switch to reporting a 4k blocksize when
i_max_bytes is that small? Then you can multiply the other values by 1k
and it should all be correct.
-- 
Jeff Layton <jlayton@kernel.org>

      parent reply	other threads:[~2021-11-09 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09  9:10 [PATCH v1 0/1] ceph: Fix incorrect statfs report khiremat
2021-11-09  9:10 ` [PATCH v1 1/1] ceph: Fix incorrect statfs report for small quota khiremat
2021-11-09 14:43   ` Luís Henriques
2021-11-09 17:02   ` Jeff Layton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=930ef6492acab416c5a4fd43ada6b16daec4048e.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=khiremat@redhat.com \
    --cc=pdonnell@redhat.com \
    --cc=vshankar@redhat.com \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.