All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH 9-10/10] Quota support for disabling sparse feature
@ 2009-07-28 10:18 Jan Kara
  2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature Jan Kara
  2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 10/10] Fix tunefs space check when " Jan Kara
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Kara @ 2009-07-28 10:18 UTC (permalink / raw)
  To: ocfs2-devel


  Hi,

  I'm sending a patch for proper quota support when disabling sparse feature.
The second patch fixes a minor problem in tunefs.ocfs2 when disabling the
sparse feature. In a few days I plan to resend the whole "quota support" series
with all the changes people request included...

									Honza

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature
  2009-07-28 10:18 [Ocfs2-devel] [PATCH 9-10/10] Quota support for disabling sparse feature Jan Kara
@ 2009-07-28 10:18 ` Jan Kara
  2009-07-29  1:39   ` Joel Becker
  2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 10/10] Fix tunefs space check when " Jan Kara
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Kara @ 2009-07-28 10:18 UTC (permalink / raw)
  To: ocfs2-devel

When filling holes after disabling SPARSE feature, we have to
properly update quota information.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 tunefs.ocfs2/feature_sparse_files.c |   68 ++++++++++++++++++++++++++++++++--
 1 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/tunefs.ocfs2/feature_sparse_files.c b/tunefs.ocfs2/feature_sparse_files.c
index 044523f..65db46b 100644
--- a/tunefs.ocfs2/feature_sparse_files.c
+++ b/tunefs.ocfs2/feature_sparse_files.c
@@ -53,6 +53,7 @@ struct sparse_file {
 	uint32_t holes_num;
 	uint32_t hole_clusters;
 	int truncate;
+	uint32_t old_clusters;
 };
 
 struct fill_hole_context {
@@ -295,6 +296,7 @@ static errcode_t hole_iterate(ocfs2_filesys *fs, struct ocfs2_dinode *di,
 
 	file->blkno = di->i_blkno;
 	INIT_LIST_HEAD(&file->holes);
+	file->old_clusters = di->i_clusters;
 	ret = find_holes_in_file(fs, di, file);
 	if (ret)
 		goto bail;
@@ -439,6 +441,8 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
 	struct list_head *pos;
 	struct sparse_file *file;
 	struct tools_progress *prog;
+	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
+	int has_usrquota, has_grpquota;
 
 	prog = tools_progress_start("Filling holes", "filling",
 				    ctxt->holecount);
@@ -447,6 +451,27 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
 		goto out;
 	}
 
+	has_usrquota = OCFS2_HAS_RO_COMPAT_FEATURE(super,
+					OCFS2_FEATURE_RO_COMPAT_USRQUOTA);
+	has_grpquota = OCFS2_HAS_RO_COMPAT_FEATURE(super,
+					OCFS2_FEATURE_RO_COMPAT_GRPQUOTA);
+	if (has_usrquota) {
+		ret = ocfs2_init_fs_quota_info(fs, USRQUOTA);
+		if (ret)
+			goto out;
+		ret = ocfs2_read_global_quota_info(fs, USRQUOTA);
+		if (ret)
+			goto out;
+	}
+	if (has_grpquota) {
+		ret = ocfs2_init_fs_quota_info(fs, GRPQUOTA);
+		if (ret)
+			goto out;
+		ret = ocfs2_read_global_quota_info(fs, GRPQUOTA);
+		if (ret)
+			goto out;
+	}
+
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
 	if (ret)
 		goto out;
@@ -458,16 +483,51 @@ static errcode_t fill_sparse_files(ocfs2_filesys *fs,
 		if (ret)
 			break;
 
-		if (!file->truncate)
+		if (!file->truncate && !has_usrquota && !has_grpquota)
 			continue;
 
 		ret = ocfs2_read_inode(fs, file->blkno, buf);
 		if (ret)
 			break;
 		di = (struct ocfs2_dinode *)buf;
-		ret = truncate_to_i_size(fs, di, NULL);
-		if (ret)
-			break;
+		if (file->truncate) {
+			ret = truncate_to_i_size(fs, di, NULL);
+			if (ret)
+				break;
+		}
+		if (di->i_clusters != file->old_clusters) {
+			long long change;
+			ocfs2_cached_dquot *udquot, *gdquot;
+
+			if (di->i_clusters > file->old_clusters) {
+				change = ocfs2_clusters_to_bytes(fs,
+					di->i_clusters - file->old_clusters);
+			} else {
+				change = -ocfs2_clusters_to_bytes(fs,
+					file->old_clusters - di->i_clusters);
+			}
+
+			if (has_usrquota) {
+				ret = ocfs2_read_dquot(fs, USRQUOTA, di->i_uid,
+						       &udquot);
+				if (ret)
+					break;
+				udquot->d_ddquot.dqb_curspace += change;
+				ret = ocfs2_write_dquot(fs, USRQUOTA, udquot);
+				if (ret)
+					break;
+			}
+			if (has_grpquota) {
+				ret = ocfs2_read_dquot(fs, GRPQUOTA, di->i_gid,
+						       &gdquot);
+				if (ret)
+					break;
+				gdquot->d_ddquot.dqb_curspace += change;
+				ret = ocfs2_write_dquot(fs, GRPQUOTA, gdquot);
+				if (ret)
+					break;
+			}
+		}
 	}
 
 	ocfs2_free(&buf);
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Ocfs2-devel] [PATCH 10/10] Fix tunefs space check when disabling SPARSE feature
  2009-07-28 10:18 [Ocfs2-devel] [PATCH 9-10/10] Quota support for disabling sparse feature Jan Kara
  2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature Jan Kara
@ 2009-07-28 10:18 ` Jan Kara
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kara @ 2009-07-28 10:18 UTC (permalink / raw)
  To: ocfs2-devel

Tunefs missed addition of number clusters needed to fill holes when disabling
SPARSE feature and hence the check whether there's enough space in the
filesystem didn't work.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 tunefs.ocfs2/feature_sparse_files.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tunefs.ocfs2/feature_sparse_files.c b/tunefs.ocfs2/feature_sparse_files.c
index 65db46b..e5b3dab 100644
--- a/tunefs.ocfs2/feature_sparse_files.c
+++ b/tunefs.ocfs2/feature_sparse_files.c
@@ -321,6 +321,7 @@ static errcode_t hole_iterate(ocfs2_filesys *fs, struct ocfs2_dinode *di,
 
 	list_add_tail(&file->list, &ctxt->files);
 	ctxt->holecount += file->holes_num;
+	ctxt->more_clusters += file->hole_clusters;
 
 	tools_progress_step(ctxt->prog, 1);
 
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature
  2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature Jan Kara
@ 2009-07-29  1:39   ` Joel Becker
  2009-07-29 10:12     ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Becker @ 2009-07-29  1:39 UTC (permalink / raw)
  To: ocfs2-devel

On Tue, Jul 28, 2009 at 12:18:41PM +0200, Jan Kara wrote:
> When filling holes after disabling SPARSE feature, we have to
> properly update quota information.

I read this as we adjust the quota but don't enforce it.  That is, if
filling a hole will make a user over quota, we allow that to happen.
Right?

Joel

-- 

"You must remember this:
 A kiss is just a kiss,
 A sigh is just a sigh.
 The fundamental rules apply
 As time goes by."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature
  2009-07-29  1:39   ` Joel Becker
@ 2009-07-29 10:12     ` Jan Kara
  2009-07-29 18:32       ` Joel Becker
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2009-07-29 10:12 UTC (permalink / raw)
  To: ocfs2-devel

On Tue 28-07-09 18:39:45, Joel Becker wrote:
> On Tue, Jul 28, 2009 at 12:18:41PM +0200, Jan Kara wrote:
> > When filling holes after disabling SPARSE feature, we have to
> > properly update quota information.
> 
> I read this as we adjust the quota but don't enforce it.  That is, if
> filling a hole will make a user over quota, we allow that to happen.
> Right?
  Yes, that's what I've decided makes the most sense. It's in the spirit
of "superuser ignores quota limits". Alternatively, we could issue a
warning or even fail the conversion when some user would go over quota
limit but I don't really see the use case.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature
  2009-07-29 10:12     ` Jan Kara
@ 2009-07-29 18:32       ` Joel Becker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Becker @ 2009-07-29 18:32 UTC (permalink / raw)
  To: ocfs2-devel

On Wed, Jul 29, 2009 at 12:12:45PM +0200, Jan Kara wrote:
> On Tue 28-07-09 18:39:45, Joel Becker wrote:
> > I read this as we adjust the quota but don't enforce it.  That is, if
> > filling a hole will make a user over quota, we allow that to happen.
> > Right?
>   Yes, that's what I've decided makes the most sense. It's in the spirit
> of "superuser ignores quota limits". Alternatively, we could issue a
> warning or even fail the conversion when some user would go over quota
> limit but I don't really see the use case.

	I agree, the superuser is asking for sparse to be removed, and
they have no quota.  Upon remount, the regular user obviously can't
create anything until they get below quota.  So this is the right
behavior.

Joel

-- 

"Sometimes one pays most for the things one gets for nothing."
        - Albert Einstein

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-29 18:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-28 10:18 [Ocfs2-devel] [PATCH 9-10/10] Quota support for disabling sparse feature Jan Kara
2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 09/10] Implement quota support for disabling SPARSE feature Jan Kara
2009-07-29  1:39   ` Joel Becker
2009-07-29 10:12     ` Jan Kara
2009-07-29 18:32       ` Joel Becker
2009-07-28 10:18 ` [Ocfs2-devel] [PATCH 10/10] Fix tunefs space check when " Jan Kara

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.