Skip to contentSkip to conversation

FS: btrfs, use helpers for rlimits

PATCH In review Jiri Slaby 2 participants 3 messages Feb 10, 2010 – Sep 3, 2010 Btrfs file system

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 FS: btrfs, use helpers for rlimits

Make sure compiler won't do weird things with limits. E.g. fetching them twice may return 2 different values after writable limits are implemented.

I.e. either use rlimit helpers added in
3e10e716abf3c71bdb5d86b8f507f9e72236c9cd
or ACCESS_ONCE if not applicable.

---
 fs/btrfs/inode.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
index c41db6d..5aa0cef 100644
@@ -3256,8 +3256,7 @@ static int btrfs_setattr_size(struct inode *inode, struct iattr *attr)
 		return 0;
 
 	if (attr->ia_size > inode->i_size) {
-		unsigned long limit;
-		limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+		unsigned long limit = rlimit(RLIMIT_FSIZE);
 		if (attr->ia_size > inode->i_sb->s_maxbytes)
 			return -EFBIG;
 		if (limit != RLIM_INFINITY && attr->ia_size > limit) {
Signature · 1 line
1.6.6.1
#1 lore raw

Thanks, I have this queued up for .34

-chris

Quoted 32 lines · Jiri Slaby

Make sure compiler won't do weird things with limits. E.g. fetching them twice may return 2 different values after writable limits are implemented.

I.e. either use rlimit helpers added in
3e10e716abf3c71bdb5d86b8f507f9e72236c9cd
or ACCESS_ONCE if not applicable.

---
 fs/btrfs/inode.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
index c41db6d..5aa0cef 100644
@@ -3256,8 +3256,7 @@ static int btrfs_setattr_size(struct inode *inode, struct iattr *attr)
 		return 0;
 
 	if (attr->ia_size > inode->i_size) {
-		unsigned long limit;
-		limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+		unsigned long limit = rlimit(RLIMIT_FSIZE);
 		if (attr->ia_size > inode->i_sb->s_maxbytes)
 			return -EFBIG;
 		if (limit != RLIM_INFINITY && attr->ia_size > limit) {
Signature · 1 line
1.6.6.1
author
#2 lore raw
Quoted 1 line · Chris Mason

Thanks, I have this queued up for .34

Hi, this is still not merged. Was it lost?

Quoted 33 lines · Jiri Slaby
Quoted 32 lines

Make sure compiler won't do weird things with limits. E.g. fetching them twice may return 2 different values after writable limits are implemented.

I.e. either use rlimit helpers added in
3e10e716abf3c71bdb5d86b8f507f9e72236c9cd
or ACCESS_ONCE if not applicable.

---
 fs/btrfs/inode.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/inode.c +1 -2
index c41db6d..5aa0cef 100644
@@ -3256,8 +3256,7 @@ static int btrfs_setattr_size(struct inode *inode, struct iattr *attr)
 		return 0;
 
 	if (attr->ia_size > inode->i_size) {
-		unsigned long limit;
-		limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+		unsigned long limit = rlimit(RLIMIT_FSIZE);
 		if (attr->ia_size > inode->i_sb->s_maxbytes)
 			return -EFBIG;
 		if (limit != RLIM_INFINITY && attr->ia_size > limit) {
Signature · 1 line
1.6.6.1
Signature · 2 lines
js
suse labs