summaryrefslogtreecommitdiffstats
path: root/fs/minix
diff options
context:
space:
mode:
Diffstat (limited to 'fs/minix')
-rw-r--r--fs/minix/bitmap.c34
-rw-r--r--fs/minix/file.c1
-rw-r--r--fs/minix/inode.c26
-rw-r--r--fs/minix/namei.c22
-rw-r--r--fs/minix/truncate.c35
5 files changed, 78 insertions, 40 deletions
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index 8c396f3e6..060d5b26c 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -16,6 +16,8 @@
#include <linux/stat.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/locks.h>
+#include <linux/quotaops.h>
#include <asm/bitops.h>
@@ -51,8 +53,9 @@ static unsigned long count_free(struct buffer_head *map[], unsigned numblocks, _
return(sum);
}
-void minix_free_block(struct super_block * sb, int block)
+void minix_free_block(struct inode * inode, int block)
{
+ struct super_block * sb = inode->i_sb;
struct buffer_head * bh;
unsigned int bit,zone;
@@ -80,12 +83,15 @@ void minix_free_block(struct super_block * sb, int block)
if (!minix_clear_bit(bit,bh->b_data))
printk("free_block (%s:%d): bit already cleared\n",
kdevname(sb->s_dev), block);
+ else
+ DQUOT_FREE_BLOCK(sb, inode, 1);
mark_buffer_dirty(bh, 1);
return;
}
-int minix_new_block(struct super_block * sb)
+int minix_new_block(struct inode * inode)
{
+ struct super_block * sb = inode->i_sb;
struct buffer_head * bh;
int i,j;
@@ -94,6 +100,9 @@ int minix_new_block(struct super_block * sb)
return 0;
}
repeat:
+ if(DQUOT_ALLOC_BLOCK(sb, inode, 1))
+ return -EDQUOT;
+
j = 8192;
bh = NULL;
for (i = 0; i < sb->u.minix_sb.s_zmap_blocks; i++) {
@@ -105,6 +114,7 @@ repeat:
return 0;
if (minix_set_bit(j,bh->b_data)) {
printk("new_block: bit already set");
+ DQUOT_FREE_BLOCK(sb, inode, 1);
goto repeat;
}
mark_buffer_dirty(bh, 1);
@@ -222,6 +232,10 @@ void minix_free_inode(struct inode * inode)
printk("free_inode: nonexistent imap in superblock\n");
return;
}
+
+ DQUOT_FREE_INODE(inode->i_sb, inode);
+ DQUOT_DROP(inode);
+
bh = inode->i_sb->u.minix_sb.s_imap[ino >> 13];
minix_clear_inode(inode);
clear_inode(inode);
@@ -230,7 +244,7 @@ void minix_free_inode(struct inode * inode)
mark_buffer_dirty(bh, 1);
}
-struct inode * minix_new_inode(const struct inode * dir)
+struct inode * minix_new_inode(const struct inode * dir, int * error)
{
struct super_block * sb;
struct inode * inode;
@@ -274,6 +288,20 @@ struct inode * minix_new_inode(const struct inode * dir)
inode->i_blocks = inode->i_blksize = 0;
insert_inode_hash(inode);
mark_inode_dirty(inode);
+
+ unlock_super(sb);
+printk("m_n_i: allocated inode ");
+ if(DQUOT_ALLOC_INODE(sb, inode)) {
+printk("fails quota test\n");
+ sb->dq_op->drop(inode);
+ inode->i_nlink = 0;
+ iput(inode);
+ *error = -EDQUOT;
+ return NULL;
+ }
+printk("is within quota\n");
+
+ *error = 0;
return inode;
}
diff --git a/fs/minix/file.c b/fs/minix/file.c
index 9eab1fb17..6683c393c 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -24,6 +24,7 @@
#define MAX(a,b) (((a)>(b))?(a):(b))
#include <linux/fs.h>
+#include <linux/minix_fs.h>
/*
* Write to a file (through the page cache).
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index e5352090d..6cc9522fa 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -518,7 +518,7 @@ repeat:
}
}
- tmp = minix_new_block(inode->i_sb);
+ tmp = minix_new_block(inode);
if (!tmp) {
*err = -ENOSPC;
return NULL;
@@ -526,7 +526,7 @@ repeat:
if (metadata) {
result = getblk(inode->i_dev, tmp, BLOCK_SIZE);
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -540,7 +540,7 @@ repeat:
* state from under us:
*/
BUG();
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
goto repeat;
}
*phys = tmp;
@@ -599,13 +599,13 @@ repeat:
}
}
- tmp = minix_new_block(inode->i_sb);
+ tmp = minix_new_block(inode);
if (!tmp)
goto out;
if (metadata) {
result = getblk(bh->b_dev, tmp, BLOCK_SIZE);
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -617,7 +617,7 @@ repeat:
*new = 1;
}
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -754,7 +754,7 @@ repeat:
}
}
- tmp = minix_new_block(inode->i_sb);
+ tmp = minix_new_block(inode);
if (!tmp) {
*err = -ENOSPC;
return NULL;
@@ -762,7 +762,7 @@ repeat:
if (metadata) {
result = getblk(inode->i_dev, tmp, BLOCK_SIZE);
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -776,7 +776,7 @@ repeat:
* state from under us:
*/
BUG();
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
goto repeat;
}
*phys = tmp;
@@ -835,13 +835,13 @@ repeat:
}
}
- tmp = minix_new_block(inode->i_sb);
+ tmp = minix_new_block(inode);
if (!tmp)
goto out;
if (metadata) {
result = getblk(bh->b_dev, tmp, BLOCK_SIZE);
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -853,7 +853,7 @@ repeat:
*new = 1;
}
if (*p) {
- minix_free_block(inode->i_sb, tmp);
+ minix_free_block(inode, tmp);
brelse(result);
goto repeat;
}
@@ -1238,7 +1238,7 @@ static struct file_system_type minix_fs_type = {
NULL
};
-__initfunc(int init_minix_fs(void))
+int __init init_minix_fs(void)
{
return register_filesystem(&minix_fs_type);
}
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index ae5aa8a5a..b268a4676 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -11,6 +11,7 @@
#include <linux/stat.h>
#include <linux/fcntl.h>
#include <linux/errno.h>
+#include <linux/quotaops.h>
#include <asm/uaccess.h>
@@ -212,7 +213,9 @@ int minix_create(struct inode * dir, struct dentry *dentry, int mode)
struct buffer_head * bh;
struct minix_dir_entry * de;
- inode = minix_new_inode(dir);
+ inode = minix_new_inode(dir, &error);
+ if (error)
+ return error;
if (!inode)
return -ENOSPC;
inode->i_op = &minix_file_inode_operations;
@@ -240,7 +243,9 @@ int minix_mknod(struct inode * dir, struct dentry *dentry, int mode, int rdev)
struct buffer_head * bh;
struct minix_dir_entry * de;
- inode = minix_new_inode(dir);
+ inode = minix_new_inode(dir, &error);
+ if (error)
+ return error;
if (!inode)
return -ENOSPC;
inode->i_uid = current->fsuid;
@@ -271,7 +276,9 @@ int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
info = &dir->i_sb->u.minix_sb;
if (dir->i_nlink >= info->s_link_max)
return -EMLINK;
- inode = minix_new_inode(dir);
+ inode = minix_new_inode(dir, &error);
+ if (error)
+ return error;
if (!inode)
return -ENOSPC;
inode->i_op = &minix_dir_inode_operations;
@@ -383,6 +390,7 @@ int minix_rmdir(struct inode * dir, struct dentry *dentry)
if (!bh)
goto end_rmdir;
inode = dentry->d_inode;
+ DQUOT_INIT(inode);
if (!empty_dir(inode)) {
retval = -ENOTEMPTY;
@@ -422,6 +430,7 @@ int minix_unlink(struct inode * dir, struct dentry *dentry)
retval = -ENOENT;
inode = dentry->d_inode;
+ DQUOT_INIT(inode);
bh = minix_find_entry(dir, dentry->d_name.name,
dentry->d_name.len, &de);
if (!bh || de->inode != inode->i_ino)
@@ -456,7 +465,10 @@ int minix_symlink(struct inode * dir, struct dentry *dentry,
int i;
char c;
- if (!(inode = minix_new_inode(dir)))
+ inode = minix_new_inode(dir, &i);
+ if (i)
+ return i;
+ if (!inode)
return -ENOSPC;
inode->i_mode = S_IFLNK | 0777;
@@ -554,6 +566,8 @@ int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
if (!new_inode) {
brelse(new_bh);
new_bh = NULL;
+ } else {
+ DQUOT_INIT(new_inode);
}
}
if (S_ISDIR(old_inode->i_mode)) {
diff --git a/fs/minix/truncate.c b/fs/minix/truncate.c
index 6724d0064..f26aa086c 100644
--- a/fs/minix/truncate.c
+++ b/fs/minix/truncate.c
@@ -62,11 +62,8 @@ repeat:
}
*p = 0;
mark_inode_dirty(inode);
- if (bh) {
- mark_buffer_clean(bh);
- brelse(bh);
- }
- minix_free_block(inode->i_sb,tmp);
+ bforget(bh);
+ minix_free_block(inode,tmp);
}
return retry;
}
@@ -113,8 +110,8 @@ repeat:
}
*ind = 0;
mark_buffer_dirty(ind_bh, 1);
- brelse(bh);
- minix_free_block(inode->i_sb,tmp);
+ bforget(bh);
+ minix_free_block(inode,tmp);
}
ind = (unsigned short *) ind_bh->b_data;
for (i = 0; i < 512; i++)
@@ -126,7 +123,7 @@ repeat:
else {
tmp = *p;
*p = 0;
- minix_free_block(inode->i_sb,tmp);
+ minix_free_block(inode,tmp);
}
}
brelse(ind_bh);
@@ -172,7 +169,7 @@ repeat:
tmp = *p;
*p = 0;
mark_inode_dirty(inode);
- minix_free_block(inode->i_sb,tmp);
+ minix_free_block(inode,tmp);
}
}
brelse(dind_bh);
@@ -226,11 +223,8 @@ repeat:
}
*p = 0;
mark_inode_dirty(inode);
- if (bh) {
- mark_buffer_clean(bh);
- brelse(bh);
- }
- minix_free_block(inode->i_sb,tmp);
+ bforget(bh);
+ minix_free_block(inode,tmp);
}
return retry;
}
@@ -277,8 +271,8 @@ repeat:
}
*ind = 0;
mark_buffer_dirty(ind_bh, 1);
- brelse(bh);
- minix_free_block(inode->i_sb,tmp);
+ bforget(bh);
+ minix_free_block(inode,tmp);
}
ind = (unsigned long *) ind_bh->b_data;
for (i = 0; i < 256; i++)
@@ -290,7 +284,7 @@ repeat:
else {
tmp = *p;
*p = 0;
- minix_free_block(inode->i_sb,tmp);
+ minix_free_block(inode,tmp);
}
}
brelse(ind_bh);
@@ -336,7 +330,7 @@ repeat:
tmp = *p;
*p = 0;
mark_inode_dirty(inode);
- minix_free_block(inode->i_sb,tmp);
+ minix_free_block(inode,tmp);
}
}
brelse(dind_bh);
@@ -382,7 +376,7 @@ repeat:
tmp = *p;
*p = 0;
mark_inode_dirty(inode);
- minix_free_block(inode->i_sb,tmp);
+ minix_free_block(inode,tmp);
}
}
brelse(tind_bh);
@@ -406,7 +400,8 @@ static void V2_minix_truncate(struct inode * inode)
(unsigned long *) inode->u.minix_i.u.i2_data + 9);
if (!retry)
break;
- current->counter = 0;
+ run_task_queue(&tq_disk);
+ current->policy |= SCHED_YIELD;
schedule();
}
inode->i_mtime = inode->i_ctime = CURRENT_TIME;