aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_address.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-06-14 15:32:57 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-06-14 15:32:57 -0400
commitfeaa7bba026c181ce071d5a4884f7f9dd26207a1 (patch)
treec858deb225917265cb07820730e9764674d133e8 /fs/gfs2/ops_address.c
parent22da645fd6675b7abc55cf937ddf6132f343e5b9 (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_address.c')
-rw-r--r--fs/gfs2/ops_address.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 16d3ebd32092..207363aed112 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -81,7 +81,6 @@ int gfs2_get_block(struct inode *inode, sector_t lblock,
81static int get_block_noalloc(struct inode *inode, sector_t lblock, 81static int get_block_noalloc(struct inode *inode, sector_t lblock,
82 struct buffer_head *bh_result, int create) 82 struct buffer_head *bh_result, int create)
83{ 83{
84 struct gfs2_inode *ip = inode->u.generic_ip;
85 int new = 0; 84 int new = 0;
86 uint64_t dblock; 85 uint64_t dblock;
87 int error; 86 int error;
@@ -93,7 +92,7 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock,
93 92
94 if (dblock) 93 if (dblock)
95 map_bh(bh_result, inode->i_sb, dblock); 94 map_bh(bh_result, inode->i_sb, dblock);
96 else if (gfs2_assert_withdraw(ip->i_sbd, !create)) 95 else if (gfs2_assert_withdraw(GFS2_SB(inode), !create))
97 error = -EIO; 96 error = -EIO;
98 if (boundary) 97 if (boundary)
99 set_buffer_boundary(bh_result); 98 set_buffer_boundary(bh_result);
@@ -114,8 +113,8 @@ static int get_block_noalloc(struct inode *inode, sector_t lblock,
114static int gfs2_writepage(struct page *page, struct writeback_control *wbc) 113static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
115{ 114{
116 struct inode *inode = page->mapping->host; 115 struct inode *inode = page->mapping->host;
117 struct gfs2_inode *ip = page->mapping->host->u.generic_ip; 116 struct gfs2_inode *ip = GFS2_I(page->mapping->host);
118 struct gfs2_sbd *sdp = ip->i_sbd; 117 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
119 loff_t i_size = i_size_read(inode); 118 loff_t i_size = i_size_read(inode);
120 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT; 119 pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
121 unsigned offset; 120 unsigned offset;
@@ -216,8 +215,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
216 215
217static int gfs2_readpage(struct file *file, struct page *page) 216static int gfs2_readpage(struct file *file, struct page *page)
218{ 217{
219 struct gfs2_inode *ip = page->mapping->host->u.generic_ip; 218 struct gfs2_inode *ip = GFS2_I(page->mapping->host);
220 struct gfs2_sbd *sdp = ip->i_sbd; 219 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
221 struct gfs2_holder gh; 220 struct gfs2_holder gh;
222 int error; 221 int error;
223 222
@@ -271,8 +270,8 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
271 struct list_head *pages, unsigned nr_pages) 270 struct list_head *pages, unsigned nr_pages)
272{ 271{
273 struct inode *inode = mapping->host; 272 struct inode *inode = mapping->host;
274 struct gfs2_inode *ip = inode->u.generic_ip; 273 struct gfs2_inode *ip = GFS2_I(inode);
275 struct gfs2_sbd *sdp = ip->i_sbd; 274 struct gfs2_sbd *sdp = GFS2_SB(inode);
276 struct gfs2_holder gh; 275 struct gfs2_holder gh;
277 unsigned page_idx; 276 unsigned page_idx;
278 int ret; 277 int ret;
@@ -345,8 +344,8 @@ out_unlock:
345static int gfs2_prepare_write(struct file *file, struct page *page, 344static int gfs2_prepare_write(struct file *file, struct page *page,
346 unsigned from, unsigned to) 345 unsigned from, unsigned to)
347{ 346{
348 struct gfs2_inode *ip = page->mapping->host->u.generic_ip; 347 struct gfs2_inode *ip = GFS2_I(page->mapping->host);
349 struct gfs2_sbd *sdp = ip->i_sbd; 348 struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
350 unsigned int data_blocks, ind_blocks, rblocks; 349 unsigned int data_blocks, ind_blocks, rblocks;
351 int alloc_required; 350 int alloc_required;
352 int error = 0; 351 int error = 0;
@@ -440,8 +439,8 @@ static int gfs2_commit_write(struct file *file, struct page *page,
440 unsigned from, unsigned to) 439 unsigned from, unsigned to)
441{ 440{
442 struct inode *inode = page->mapping->host; 441 struct inode *inode = page->mapping->host;
443 struct gfs2_inode *ip = inode->u.generic_ip; 442 struct gfs2_inode *ip = GFS2_I(inode);
444 struct gfs2_sbd *sdp = ip->i_sbd; 443 struct gfs2_sbd *sdp = GFS2_SB(inode);
445 int error = -EOPNOTSUPP; 444 int error = -EOPNOTSUPP;
446 struct buffer_head *dibh; 445 struct buffer_head *dibh;
447 struct gfs2_alloc *al = &ip->i_alloc;; 446 struct gfs2_alloc *al = &ip->i_alloc;;
@@ -520,7 +519,7 @@ fail_nounlock:
520 519
521static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock) 520static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)
522{ 521{
523 struct gfs2_inode *ip = mapping->host->u.generic_ip; 522 struct gfs2_inode *ip = GFS2_I(mapping->host);
524 struct gfs2_holder i_gh; 523 struct gfs2_holder i_gh;
525 sector_t dblock = 0; 524 sector_t dblock = 0;
526 int error; 525 int error;
@@ -594,7 +593,7 @@ static ssize_t gfs2_direct_IO_write(struct kiocb *iocb, const struct iovec *iov,
594{ 593{
595 struct file *file = iocb->ki_filp; 594 struct file *file = iocb->ki_filp;
596 struct inode *inode = file->f_mapping->host; 595 struct inode *inode = file->f_mapping->host;
597 struct gfs2_inode *ip = inode->u.generic_ip; 596 struct gfs2_inode *ip = GFS2_I(inode);
598 struct gfs2_holder gh; 597 struct gfs2_holder gh;
599 int rv; 598 int rv;
600 599
@@ -641,8 +640,8 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
641{ 640{
642 struct file *file = iocb->ki_filp; 641 struct file *file = iocb->ki_filp;
643 struct inode *inode = file->f_mapping->host; 642 struct inode *inode = file->f_mapping->host;
644 struct gfs2_inode *ip = inode->u.generic_ip; 643 struct gfs2_inode *ip = GFS2_I(inode);
645 struct gfs2_sbd *sdp = ip->i_sbd; 644 struct gfs2_sbd *sdp = GFS2_SB(inode);
646 645
647 if (rw == WRITE) 646 if (rw == WRITE)
648 return gfs2_direct_IO_write(iocb, iov, offset, nr_segs); 647 return gfs2_direct_IO_write(iocb, iov, offset, nr_segs);