All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
@ 2010-02-25 14:00 Wengang Wang
  2010-02-25 16:11 ` Joel Becker
  0 siblings, 1 reply; 7+ messages in thread
From: Wengang Wang @ 2010-02-25 14:00 UTC (permalink / raw)
  To: ocfs2-devel

This patch makes ocfs2 send SIGXFSZ if new file size exceeds limit.
No suprise that processes get SIGXFSZ on one node(in the cluster) while they
don't on another if file size limits are different on the two nodes.

Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
---
 fs/ocfs2/file.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 558ce03..13d7c68 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -993,6 +993,14 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
 	}
 
 	if (size_change && attr->ia_size != i_size_read(inode)) {
+		unsigned long limit;
+
+		limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+		if (limit != RLIM_INFINITY && attr->ia_size > limit) {
+			status = -EFBIG;
+			send_sig(SIGXFSZ, current, 0);
+			goto bail_unlock;
+		}
 		if (attr->ia_size > sb->s_maxbytes) {
 			status = -EFBIG;
 			goto bail_unlock;
-- 
1.6.6

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

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-25 14:00 [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit Wengang Wang
@ 2010-02-25 16:11 ` Joel Becker
  2010-02-25 16:29   ` Wengang Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Becker @ 2010-02-25 16:11 UTC (permalink / raw)
  To: ocfs2-devel

On Thu, Feb 25, 2010 at 10:00:59PM +0800, Wengang Wang wrote:
> This patch makes ocfs2 send SIGXFSZ if new file size exceeds limit.
> No suprise that processes get SIGXFSZ on one node(in the cluster) while they
> don't on another if file size limits are different on the two nodes.

	Why aren't you using inode_newsize_ok()?

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] 7+ messages in thread

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-25 16:11 ` Joel Becker
@ 2010-02-25 16:29   ` Wengang Wang
  2010-02-25 20:01     ` Joel Becker
  0 siblings, 1 reply; 7+ messages in thread
From: Wengang Wang @ 2010-02-25 16:29 UTC (permalink / raw)
  To: ocfs2-devel

Joel,

Yes that I considered using inode_newsize_ok().
I'am not sure if checking i_size is safe(lack of knowledge).

regards,
wengang.
On 10-02-25 08:11, Joel Becker wrote:
> On Thu, Feb 25, 2010 at 10:00:59PM +0800, Wengang Wang wrote:
> > This patch makes ocfs2 send SIGXFSZ if new file size exceeds limit.
> > No suprise that processes get SIGXFSZ on one node(in the cluster) while they
> > don't on another if file size limits are different on the two nodes.
> 
> 	Why aren't you using inode_newsize_ok()?
> 
> Joel

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

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-25 16:29   ` Wengang Wang
@ 2010-02-25 20:01     ` Joel Becker
  2010-02-26  2:18       ` Wengang Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Becker @ 2010-02-25 20:01 UTC (permalink / raw)
  To: ocfs2-devel

On Fri, Feb 26, 2010 at 12:29:19AM +0800, Wengang Wang wrote:
> Yes that I considered using inode_newsize_ok().
> I'am not sure if checking i_size is safe(lack of knowledge).

	It should be, given that i_mutex is held.  Filesystems that
don't handle their own setattr get to inode_newsize_ok() via
vmtruncate.

Joel


-- 

"Time is an illusion, lunchtime doubly so."
        -Douglas Adams

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

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

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-25 20:01     ` Joel Becker
@ 2010-02-26  2:18       ` Wengang Wang
  2010-02-26  5:55         ` Joel Becker
  0 siblings, 1 reply; 7+ messages in thread
From: Wengang Wang @ 2010-02-26  2:18 UTC (permalink / raw)
  To: ocfs2-devel

Joel,

On 10-02-25 12:01, Joel Becker wrote:
> On Fri, Feb 26, 2010 at 12:29:19AM +0800, Wengang Wang wrote:
> > Yes that I considered using inode_newsize_ok().
> > I'am not sure if checking i_size is safe(lack of knowledge).
> 
> 	It should be, given that i_mutex is held.  Filesystems that
> don't handle their own setattr get to inode_newsize_ok() via
> vmtruncate.

What if this case:
0) there is a file with size 4k.
1) user sets file max size to 1k.
2) user resize the 4k-size file to 2k.

If we go with inode_newsize_ok(), the operation succeeds. But doesn't it
disobey the file size limit?
I didn't find a explicit description for that case. But I prefer that
step 2) fails.

regards,
wengang.

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

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-26  2:18       ` Wengang Wang
@ 2010-02-26  5:55         ` Joel Becker
  2010-02-26  6:08           ` Wengang Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Becker @ 2010-02-26  5:55 UTC (permalink / raw)
  To: ocfs2-devel

On Fri, Feb 26, 2010 at 10:18:13AM +0800, Wengang Wang wrote:
> On 10-02-25 12:01, Joel Becker wrote:
> > On Fri, Feb 26, 2010 at 12:29:19AM +0800, Wengang Wang wrote:
> > > Yes that I considered using inode_newsize_ok().
> > > I'am not sure if checking i_size is safe(lack of knowledge).
> > 
> > 	It should be, given that i_mutex is held.  Filesystems that
> > don't handle their own setattr get to inode_newsize_ok() via
> > vmtruncate.
> 
> What if this case:
> 0) there is a file with size 4k.
> 1) user sets file max size to 1k.
> 2) user resize the 4k-size file to 2k.
> 
> If we go with inode_newsize_ok(), the operation succeeds. But doesn't it
> disobey the file size limit?
> I didn't find a explicit description for that case. But I prefer that
> step 2) fails.

	It was already larger.  You haven't broken anything.  I don't
know exactly what POSIX says, but since inode_newsize_ok() is the
behavior used by most or all other Linux filesystems, we should be
consistent unless we're sure POSIX disagrees.
	Wikipedia states that SIGXFSZ is only triggered when a process
causes a file to *grow* past the limit.  It doesn't mention shrinking.
Use inode_newsize_ok().

Joel

-- 

"There is no sincerer love than the love of food."  
         - George Bernard Shaw 

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

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

* [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit
  2010-02-26  5:55         ` Joel Becker
@ 2010-02-26  6:08           ` Wengang Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Wengang Wang @ 2010-02-26  6:08 UTC (permalink / raw)
  To: ocfs2-devel

On 10-02-25 21:55, Joel Becker wrote:
> On Fri, Feb 26, 2010 at 10:18:13AM +0800, Wengang Wang wrote:
> > On 10-02-25 12:01, Joel Becker wrote:
> > > On Fri, Feb 26, 2010 at 12:29:19AM +0800, Wengang Wang wrote:
> > > > Yes that I considered using inode_newsize_ok().
> > > > I'am not sure if checking i_size is safe(lack of knowledge).
> > > 
> > > 	It should be, given that i_mutex is held.  Filesystems that
> > > don't handle their own setattr get to inode_newsize_ok() via
> > > vmtruncate.
> > 
> > What if this case:
> > 0) there is a file with size 4k.
> > 1) user sets file max size to 1k.
> > 2) user resize the 4k-size file to 2k.
> > 
> > If we go with inode_newsize_ok(), the operation succeeds. But doesn't it
> > disobey the file size limit?
> > I didn't find a explicit description for that case. But I prefer that
> > step 2) fails.
> 
> 	It was already larger.  You haven't broken anything.  I don't
> know exactly what POSIX says, but since inode_newsize_ok() is the
> behavior used by most or all other Linux filesystems, we should be
> consistent unless we're sure POSIX disagrees.
> 	Wikipedia states that SIGXFSZ is only triggered when a process
> causes a file to *grow* past the limit.  It doesn't mention shrinking.
> Use inode_newsize_ok().

Ok.
I will post the revised patch later.

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

end of thread, other threads:[~2010-02-26  6:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-25 14:00 [Ocfs2-devel] [PATCH] ocfs2: send SIGXFSZ if new filesize exceeds limit Wengang Wang
2010-02-25 16:11 ` Joel Becker
2010-02-25 16:29   ` Wengang Wang
2010-02-25 20:01     ` Joel Becker
2010-02-26  2:18       ` Wengang Wang
2010-02-26  5:55         ` Joel Becker
2010-02-26  6:08           ` Wengang Wang

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.