ocfs2: send SIGXFSZ if new filesize exceeds limit
PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
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.
--- fs/ocfs2/file.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
fs/ocfs2/file.c +8 -0
@@ -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;
Signature · 1 line
1.6.6
PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Quoted 3 lines · Wengang Wang
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
Signature · 11 lines
"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
PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Joel,
Yes that I considered using inode_newsize_ok(). I'am not sure if checking i_size is safe(lack of knowledge).
regards,
wengang.
Quoted 8 lines · Joel Becker
Quoted 3 lines · Wengang Wang
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
PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Quoted 2 lines · Wengang Wang
Yes that I considered using
inode_newsize_ok(). I'am not sure if checkingi_sizeis 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
Signature · 8 lines
"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-8127PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Joel,
Quoted 7 lines · Joel Becker
Quoted 2 lines · Wengang Wang
Yes that I considered using
inode_newsize_ok(). I'am not sure if checkingi_sizeis safe(lack of knowledge).It should be, given that
i_mutexis held. Filesystems that
don't handle their own setattr get toinode_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.
PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Quoted 14 lines · Wengang Wang
Quoted 7 lines · Joel Becker
Quoted 2 lines · Wengang Wang
Yes that I considered using
inode_newsize_ok(). I'am not sure if checkingi_sizeis safe(lack of knowledge).It should be, given that
i_mutexis held. Filesystems that
don't handle their own setattr get toinode_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.
Quoted 4 lines
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
Signature · 8 lines
"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-8127PATCH 1/1 ocfs2: send SIGXFSZ if new filesize exceeds limit
Quoted 20 lines · Joel Becker
Quoted 14 lines · Wengang Wang
Quoted 7 lines · Joel Becker
Quoted 2 lines · Wengang Wang
Yes that I considered using
inode_newsize_ok(). I'am not sure if checkingi_sizeis safe(lack of knowledge).It should be, given that
i_mutexis held. Filesystems that
don't handle their own setattr get toinode_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.Quoted 4 lines
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.
Quoted 7 lines
It was already larger. You haven't broken anything. I don't
know exactly what POSIX says, but sinceinode_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. Useinode_newsize_ok().
Ok.
I will post the revised patch later.