diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-06-14 15:32:57 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-06-14 15:32:57 -0400 |
commit | feaa7bba026c181ce071d5a4884f7f9dd26207a1 (patch) | |
tree | c858deb225917265cb07820730e9764674d133e8 /fs/gfs2/ops_file.c | |
parent | 22da645fd6675b7abc55cf937ddf6132f343e5b9 (diff) |
[GFS2] Fix unlinked file handling
This patch fixes the way we have been dealing with unlinked,
but still open files. It removes all limits (other than memory
for inodes, as per every other filesystem) on numbers of these
which we can support on GFS2. It also means that (like other
fs) its the responsibility of the last process to close the file
to deallocate the storage, rather than the person who did the
unlinking. Note that with GFS2, those two events might take place
on different nodes.
Also there are a number of other changes:
o We use the Linux inode subsystem as it was intended to be
used, wrt allocating GFS2 inodes
o The Linux inode cache is now the point which we use for
local enforcement of only holding one copy of the inode in
core at once (previous to this we used the glock layer).
o We no longer use the unlinked "special" file. We just ignore it
completely. This makes unlinking more efficient.
o We now use the 4th block allocation state. The previously unused
state is used to track unlinked but still open inodes.
o gfs2_inoded is no longer needed
o Several fields are now no longer needed (and removed) from the in
core struct gfs2_inode
o Several fields are no longer needed (and removed) from the in core
superblock
There are a number of future possible optimisations and clean ups
which have been made possible by this patch.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_file.c')
-rw-r--r-- | fs/gfs2/ops_file.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 1e8f602c1e50..222f3be3e06e 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -105,7 +105,7 @@ static int gfs2_read_actor(read_descriptor_t *desc, struct page *page, | |||
105 | int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, | 105 | int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, |
106 | char *buf, loff_t *pos, unsigned size) | 106 | char *buf, loff_t *pos, unsigned size) |
107 | { | 107 | { |
108 | struct inode *inode = ip->i_vnode; | 108 | struct inode *inode = &ip->i_inode; |
109 | read_descriptor_t desc; | 109 | read_descriptor_t desc; |
110 | desc.written = 0; | 110 | desc.written = 0; |
111 | desc.arg.buf = buf; | 111 | desc.arg.buf = buf; |
@@ -131,7 +131,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, | |||
131 | 131 | ||
132 | static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) | 132 | static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) |
133 | { | 133 | { |
134 | struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; | 134 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
135 | struct gfs2_holder i_gh; | 135 | struct gfs2_holder i_gh; |
136 | loff_t error; | 136 | loff_t error; |
137 | 137 | ||
@@ -178,7 +178,7 @@ static ssize_t __gfs2_file_aio_read(struct kiocb *iocb, | |||
178 | unsigned long nr_segs, loff_t *ppos) | 178 | unsigned long nr_segs, loff_t *ppos) |
179 | { | 179 | { |
180 | struct file *filp = iocb->ki_filp; | 180 | struct file *filp = iocb->ki_filp; |
181 | struct gfs2_inode *ip = filp->f_mapping->host->u.generic_ip; | 181 | struct gfs2_inode *ip = GFS2_I(filp->f_mapping->host); |
182 | struct gfs2_holder gh; | 182 | struct gfs2_holder gh; |
183 | ssize_t retval; | 183 | ssize_t retval; |
184 | unsigned long seg; | 184 | unsigned long seg; |
@@ -361,13 +361,13 @@ static int filldir_reg_func(void *opaque, const char *name, unsigned int length, | |||
361 | static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) | 361 | static int readdir_reg(struct file *file, void *dirent, filldir_t filldir) |
362 | { | 362 | { |
363 | struct inode *dir = file->f_mapping->host; | 363 | struct inode *dir = file->f_mapping->host; |
364 | struct gfs2_inode *dip = dir->u.generic_ip; | 364 | struct gfs2_inode *dip = GFS2_I(dir); |
365 | struct filldir_reg fdr; | 365 | struct filldir_reg fdr; |
366 | struct gfs2_holder d_gh; | 366 | struct gfs2_holder d_gh; |
367 | uint64_t offset = file->f_pos; | 367 | uint64_t offset = file->f_pos; |
368 | int error; | 368 | int error; |
369 | 369 | ||
370 | fdr.fdr_sbd = dip->i_sbd; | 370 | fdr.fdr_sbd = GFS2_SB(dir); |
371 | fdr.fdr_prefetch = 1; | 371 | fdr.fdr_prefetch = 1; |
372 | fdr.fdr_filldir = filldir; | 372 | fdr.fdr_filldir = filldir; |
373 | fdr.fdr_opaque = dirent; | 373 | fdr.fdr_opaque = dirent; |
@@ -451,8 +451,8 @@ static int filldir_bad_func(void *opaque, const char *name, unsigned int length, | |||
451 | static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) | 451 | static int readdir_bad(struct file *file, void *dirent, filldir_t filldir) |
452 | { | 452 | { |
453 | struct inode *dir = file->f_mapping->host; | 453 | struct inode *dir = file->f_mapping->host; |
454 | struct gfs2_inode *dip = dir->u.generic_ip; | 454 | struct gfs2_inode *dip = GFS2_I(dir); |
455 | struct gfs2_sbd *sdp = dip->i_sbd; | 455 | struct gfs2_sbd *sdp = GFS2_SB(dir); |
456 | struct filldir_reg fdr; | 456 | struct filldir_reg fdr; |
457 | unsigned int entries, size; | 457 | unsigned int entries, size; |
458 | struct filldir_bad *fdb; | 458 | struct filldir_bad *fdb; |
@@ -561,7 +561,7 @@ static const u32 gfs2_to_iflags[32] = { | |||
561 | static int gfs2_get_flags(struct file *filp, u32 __user *ptr) | 561 | static int gfs2_get_flags(struct file *filp, u32 __user *ptr) |
562 | { | 562 | { |
563 | struct inode *inode = filp->f_dentry->d_inode; | 563 | struct inode *inode = filp->f_dentry->d_inode; |
564 | struct gfs2_inode *ip = inode->u.generic_ip; | 564 | struct gfs2_inode *ip = GFS2_I(inode); |
565 | struct gfs2_holder gh; | 565 | struct gfs2_holder gh; |
566 | int error; | 566 | int error; |
567 | u32 iflags; | 567 | u32 iflags; |
@@ -601,8 +601,8 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr) | |||
601 | static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) | 601 | static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) |
602 | { | 602 | { |
603 | struct inode *inode = filp->f_dentry->d_inode; | 603 | struct inode *inode = filp->f_dentry->d_inode; |
604 | struct gfs2_inode *ip = inode->u.generic_ip; | 604 | struct gfs2_inode *ip = GFS2_I(inode); |
605 | struct gfs2_sbd *sdp = ip->i_sbd; | 605 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
606 | struct buffer_head *bh; | 606 | struct buffer_head *bh; |
607 | struct gfs2_holder gh; | 607 | struct gfs2_holder gh; |
608 | int error; | 608 | int error; |
@@ -693,7 +693,7 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
693 | 693 | ||
694 | static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) | 694 | static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) |
695 | { | 695 | { |
696 | struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; | 696 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
697 | struct gfs2_holder i_gh; | 697 | struct gfs2_holder i_gh; |
698 | int error; | 698 | int error; |
699 | 699 | ||
@@ -728,7 +728,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma) | |||
728 | 728 | ||
729 | static int gfs2_open(struct inode *inode, struct file *file) | 729 | static int gfs2_open(struct inode *inode, struct file *file) |
730 | { | 730 | { |
731 | struct gfs2_inode *ip = inode->u.generic_ip; | 731 | struct gfs2_inode *ip = GFS2_I(inode); |
732 | struct gfs2_holder i_gh; | 732 | struct gfs2_holder i_gh; |
733 | struct gfs2_file *fp; | 733 | struct gfs2_file *fp; |
734 | int error; | 734 | int error; |
@@ -739,7 +739,7 @@ static int gfs2_open(struct inode *inode, struct file *file) | |||
739 | 739 | ||
740 | mutex_init(&fp->f_fl_mutex); | 740 | mutex_init(&fp->f_fl_mutex); |
741 | 741 | ||
742 | gfs2_assert_warn(ip->i_sbd, !file->private_data); | 742 | gfs2_assert_warn(GFS2_SB(inode), !file->private_data); |
743 | file->private_data = fp; | 743 | file->private_data = fp; |
744 | 744 | ||
745 | if (S_ISREG(ip->i_di.di_mode)) { | 745 | if (S_ISREG(ip->i_di.di_mode)) { |
@@ -808,7 +808,7 @@ static int gfs2_close(struct inode *inode, struct file *file) | |||
808 | 808 | ||
809 | static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) | 809 | static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) |
810 | { | 810 | { |
811 | struct gfs2_inode *ip = dentry->d_inode->u.generic_ip; | 811 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
812 | 812 | ||
813 | gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); | 813 | gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); |
814 | 814 | ||
@@ -826,8 +826,8 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
826 | 826 | ||
827 | static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) | 827 | static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) |
828 | { | 828 | { |
829 | struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; | 829 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
830 | struct gfs2_sbd *sdp = ip->i_sbd; | 830 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); |
831 | struct lm_lockname name = | 831 | struct lm_lockname name = |
832 | { .ln_number = ip->i_num.no_addr, | 832 | { .ln_number = ip->i_num.no_addr, |
833 | .ln_type = LM_TYPE_PLOCK }; | 833 | .ln_type = LM_TYPE_PLOCK }; |
@@ -881,7 +881,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
881 | { | 881 | { |
882 | struct gfs2_file *fp = file->private_data; | 882 | struct gfs2_file *fp = file->private_data; |
883 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; | 883 | struct gfs2_holder *fl_gh = &fp->f_fl_gh; |
884 | struct gfs2_inode *ip = file->f_dentry->d_inode->u.generic_ip; | 884 | struct gfs2_inode *ip = GFS2_I(file->f_dentry->d_inode); |
885 | struct gfs2_glock *gl; | 885 | struct gfs2_glock *gl; |
886 | unsigned int state; | 886 | unsigned int state; |
887 | int flags; | 887 | int flags; |
@@ -901,7 +901,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
901 | &(struct file_lock){.fl_type = F_UNLCK}); | 901 | &(struct file_lock){.fl_type = F_UNLCK}); |
902 | gfs2_glock_dq_uninit(fl_gh); | 902 | gfs2_glock_dq_uninit(fl_gh); |
903 | } else { | 903 | } else { |
904 | error = gfs2_glock_get(ip->i_sbd, | 904 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), |
905 | ip->i_num.no_addr, &gfs2_flock_glops, | 905 | ip->i_num.no_addr, &gfs2_flock_glops, |
906 | CREATE, &gl); | 906 | CREATE, &gl); |
907 | if (error) | 907 | if (error) |
@@ -918,7 +918,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
918 | error = -EAGAIN; | 918 | error = -EAGAIN; |
919 | } else { | 919 | } else { |
920 | error = flock_lock_file_wait(file, fl); | 920 | error = flock_lock_file_wait(file, fl); |
921 | gfs2_assert_warn(ip->i_sbd, !error); | 921 | gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); |
922 | } | 922 | } |
923 | 923 | ||
924 | out: | 924 | out: |
@@ -950,8 +950,8 @@ static void do_unflock(struct file *file, struct file_lock *fl) | |||
950 | 950 | ||
951 | static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) | 951 | static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) |
952 | { | 952 | { |
953 | struct gfs2_inode *ip = file->f_mapping->host->u.generic_ip; | 953 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
954 | struct gfs2_sbd *sdp = ip->i_sbd; | 954 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); |
955 | 955 | ||
956 | if (!(fl->fl_flags & FL_FLOCK)) | 956 | if (!(fl->fl_flags & FL_FLOCK)) |
957 | return -ENOLCK; | 957 | return -ENOLCK; |