aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_file.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2009-01-12 05:43:39 -0500
committerSteven Whitehouse <steve@dolmen.chygwyn.com>2009-03-24 07:21:14 -0400
commitf057f6cdf64175db1151b1f5d110e29904f119a1 (patch)
tree582dbf358e351f64977620c29ebf772d693b1948 /fs/gfs2/ops_file.c
parent22077f57dec8fcbeb1112b35313961c0902ff038 (diff)
GFS2: Merge lock_dlm module into GFS2
This is the big patch that I've been working on for some time now. There are many reasons for wanting to make this change such as: o Reducing overhead by eliminating duplicated fields between structures o Simplifcation of the code (reduces the code size by a fair bit) o The locking interface is now the DLM interface itself as proposed some time ago. o Fewer lookups of glocks when processing replies from the DLM o Fewer memory allocations/deallocations for each glock o Scope to do further optimisations in the future (but this patch is more than big enough for now!) Please note that (a) this patch relates to the lock_dlm module and not the DLM itself, that is still a separate module; and (b) that we retain the ability to build GFS2 as a standalone single node filesystem with out requiring the DLM. This patch needs a lot of testing, hence my keeping it I restarted my -git tree after the last merge window. That way, this has the maximum exposure before its merged. This is (modulo a few minor bug fixes) the same patch that I've been posting on and off the the last three months and its passed a number of different tests so far. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_file.c')
-rw-r--r--fs/gfs2/ops_file.c74
1 files changed, 22 insertions, 52 deletions
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 93fe41b67f97..99d726f1c7a6 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -20,9 +20,10 @@
20#include <linux/gfs2_ondisk.h> 20#include <linux/gfs2_ondisk.h>
21#include <linux/ext2_fs.h> 21#include <linux/ext2_fs.h>
22#include <linux/crc32.h> 22#include <linux/crc32.h>
23#include <linux/lm_interface.h>
24#include <linux/writeback.h> 23#include <linux/writeback.h>
25#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <linux/dlm.h>
26#include <linux/dlm_plock.h>
26 27
27#include "gfs2.h" 28#include "gfs2.h"
28#include "incore.h" 29#include "incore.h"
@@ -560,57 +561,24 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
560 return ret; 561 return ret;
561} 562}
562 563
564#ifdef CONFIG_GFS2_FS_LOCKING_DLM
565
563/** 566/**
564 * gfs2_setlease - acquire/release a file lease 567 * gfs2_setlease - acquire/release a file lease
565 * @file: the file pointer 568 * @file: the file pointer
566 * @arg: lease type 569 * @arg: lease type
567 * @fl: file lock 570 * @fl: file lock
568 * 571 *
572 * We don't currently have a way to enforce a lease across the whole
573 * cluster; until we do, disable leases (by just returning -EINVAL),
574 * unless the administrator has requested purely local locking.
575 *
569 * Returns: errno 576 * Returns: errno
570 */ 577 */
571 578
572static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) 579static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
573{ 580{
574 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); 581 return -EINVAL;
575
576 /*
577 * We don't currently have a way to enforce a lease across the whole
578 * cluster; until we do, disable leases (by just returning -EINVAL),
579 * unless the administrator has requested purely local locking.
580 */
581 if (!sdp->sd_args.ar_localflocks)
582 return -EINVAL;
583 return generic_setlease(file, arg, fl);
584}
585
586static int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name,
587 struct file *file, struct file_lock *fl)
588{
589 int error = -EIO;
590 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
591 error = sdp->sd_lockstruct.ls_ops->lm_plock_get(
592 sdp->sd_lockstruct.ls_lockspace, name, file, fl);
593 return error;
594}
595
596static int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name,
597 struct file *file, int cmd, struct file_lock *fl)
598{
599 int error = -EIO;
600 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
601 error = sdp->sd_lockstruct.ls_ops->lm_plock(
602 sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl);
603 return error;
604}
605
606static int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name,
607 struct file *file, struct file_lock *fl)
608{
609 int error = -EIO;
610 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
611 error = sdp->sd_lockstruct.ls_ops->lm_punlock(
612 sdp->sd_lockstruct.ls_lockspace, name, file, fl);
613 return error;
614} 582}
615 583
616/** 584/**
@@ -626,9 +594,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
626{ 594{
627 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); 595 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
628 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); 596 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
629 struct lm_lockname name = 597 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
630 { .ln_number = ip->i_no_addr,
631 .ln_type = LM_TYPE_PLOCK };
632 598
633 if (!(fl->fl_flags & FL_POSIX)) 599 if (!(fl->fl_flags & FL_POSIX))
634 return -ENOLCK; 600 return -ENOLCK;
@@ -640,12 +606,14 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
640 cmd = F_SETLK; 606 cmd = F_SETLK;
641 fl->fl_type = F_UNLCK; 607 fl->fl_type = F_UNLCK;
642 } 608 }
609 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
610 return -EIO;
643 if (IS_GETLK(cmd)) 611 if (IS_GETLK(cmd))
644 return gfs2_lm_plock_get(sdp, &name, file, fl); 612 return dlm_posix_get(ls->ls_dlm, ip->i_no_addr, file, fl);
645 else if (fl->fl_type == F_UNLCK) 613 else if (fl->fl_type == F_UNLCK)
646 return gfs2_lm_punlock(sdp, &name, file, fl); 614 return dlm_posix_unlock(ls->ls_dlm, ip->i_no_addr, file, fl);
647 else 615 else
648 return gfs2_lm_plock(sdp, &name, file, cmd, fl); 616 return dlm_posix_lock(ls->ls_dlm, ip->i_no_addr, file, cmd, fl);
649} 617}
650 618
651static int do_flock(struct file *file, int cmd, struct file_lock *fl) 619static int do_flock(struct file *file, int cmd, struct file_lock *fl)
@@ -732,7 +700,7 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
732 } 700 }
733} 701}
734 702
735const struct file_operations gfs2_file_fops = { 703const struct file_operations *gfs2_file_fops = &(const struct file_operations){
736 .llseek = gfs2_llseek, 704 .llseek = gfs2_llseek,
737 .read = do_sync_read, 705 .read = do_sync_read,
738 .aio_read = generic_file_aio_read, 706 .aio_read = generic_file_aio_read,
@@ -750,7 +718,7 @@ const struct file_operations gfs2_file_fops = {
750 .setlease = gfs2_setlease, 718 .setlease = gfs2_setlease,
751}; 719};
752 720
753const struct file_operations gfs2_dir_fops = { 721const struct file_operations *gfs2_dir_fops = &(const struct file_operations){
754 .readdir = gfs2_readdir, 722 .readdir = gfs2_readdir,
755 .unlocked_ioctl = gfs2_ioctl, 723 .unlocked_ioctl = gfs2_ioctl,
756 .open = gfs2_open, 724 .open = gfs2_open,
@@ -760,7 +728,9 @@ const struct file_operations gfs2_dir_fops = {
760 .flock = gfs2_flock, 728 .flock = gfs2_flock,
761}; 729};
762 730
763const struct file_operations gfs2_file_fops_nolock = { 731#endif /* CONFIG_GFS2_FS_LOCKING_DLM */
732
733const struct file_operations *gfs2_file_fops_nolock = &(const struct file_operations){
764 .llseek = gfs2_llseek, 734 .llseek = gfs2_llseek,
765 .read = do_sync_read, 735 .read = do_sync_read,
766 .aio_read = generic_file_aio_read, 736 .aio_read = generic_file_aio_read,
@@ -773,10 +743,10 @@ const struct file_operations gfs2_file_fops_nolock = {
773 .fsync = gfs2_fsync, 743 .fsync = gfs2_fsync,
774 .splice_read = generic_file_splice_read, 744 .splice_read = generic_file_splice_read,
775 .splice_write = generic_file_splice_write, 745 .splice_write = generic_file_splice_write,
776 .setlease = gfs2_setlease, 746 .setlease = generic_setlease,
777}; 747};
778 748
779const struct file_operations gfs2_dir_fops_nolock = { 749const struct file_operations *gfs2_dir_fops_nolock = &(const struct file_operations){
780 .readdir = gfs2_readdir, 750 .readdir = gfs2_readdir,
781 .unlocked_ioctl = gfs2_ioctl, 751 .unlocked_ioctl = gfs2_ioctl,
782 .open = gfs2_open, 752 .open = gfs2_open,