aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/ops_file.c')
-rw-r--r--fs/gfs2/ops_file.c76
1 files changed, 24 insertions, 52 deletions
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 93fe41b67f97..3b9e8de3500b 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"
@@ -354,7 +355,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)
354 if (ret) 355 if (ret)
355 goto out; 356 goto out;
356 357
358 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags);
357 set_bit(GIF_SW_PAGED, &ip->i_flags); 359 set_bit(GIF_SW_PAGED, &ip->i_flags);
360
358 ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required); 361 ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required);
359 if (ret || !alloc_required) 362 if (ret || !alloc_required)
360 goto out_unlock; 363 goto out_unlock;
@@ -560,57 +563,24 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
560 return ret; 563 return ret;
561} 564}
562 565
566#ifdef CONFIG_GFS2_FS_LOCKING_DLM
567
563/** 568/**
564 * gfs2_setlease - acquire/release a file lease 569 * gfs2_setlease - acquire/release a file lease
565 * @file: the file pointer 570 * @file: the file pointer
566 * @arg: lease type 571 * @arg: lease type
567 * @fl: file lock 572 * @fl: file lock
568 * 573 *
574 * We don't currently have a way to enforce a lease across the whole
575 * cluster; until we do, disable leases (by just returning -EINVAL),
576 * unless the administrator has requested purely local locking.
577 *
569 * Returns: errno 578 * Returns: errno
570 */ 579 */
571 580
572static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) 581static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
573{ 582{
574 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); 583 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} 584}
615 585
616/** 586/**
@@ -626,9 +596,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
626{ 596{
627 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); 597 struct gfs2_inode *ip = GFS2_I(file->f_mapping->host);
628 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); 598 struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host);
629 struct lm_lockname name = 599 struct lm_lockstruct *ls = &sdp->sd_lockstruct;
630 { .ln_number = ip->i_no_addr,
631 .ln_type = LM_TYPE_PLOCK };
632 600
633 if (!(fl->fl_flags & FL_POSIX)) 601 if (!(fl->fl_flags & FL_POSIX))
634 return -ENOLCK; 602 return -ENOLCK;
@@ -640,12 +608,14 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
640 cmd = F_SETLK; 608 cmd = F_SETLK;
641 fl->fl_type = F_UNLCK; 609 fl->fl_type = F_UNLCK;
642 } 610 }
611 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
612 return -EIO;
643 if (IS_GETLK(cmd)) 613 if (IS_GETLK(cmd))
644 return gfs2_lm_plock_get(sdp, &name, file, fl); 614 return dlm_posix_get(ls->ls_dlm, ip->i_no_addr, file, fl);
645 else if (fl->fl_type == F_UNLCK) 615 else if (fl->fl_type == F_UNLCK)
646 return gfs2_lm_punlock(sdp, &name, file, fl); 616 return dlm_posix_unlock(ls->ls_dlm, ip->i_no_addr, file, fl);
647 else 617 else
648 return gfs2_lm_plock(sdp, &name, file, cmd, fl); 618 return dlm_posix_lock(ls->ls_dlm, ip->i_no_addr, file, cmd, fl);
649} 619}
650 620
651static int do_flock(struct file *file, int cmd, struct file_lock *fl) 621static int do_flock(struct file *file, int cmd, struct file_lock *fl)
@@ -732,7 +702,7 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
732 } 702 }
733} 703}
734 704
735const struct file_operations gfs2_file_fops = { 705const struct file_operations *gfs2_file_fops = &(const struct file_operations){
736 .llseek = gfs2_llseek, 706 .llseek = gfs2_llseek,
737 .read = do_sync_read, 707 .read = do_sync_read,
738 .aio_read = generic_file_aio_read, 708 .aio_read = generic_file_aio_read,
@@ -750,7 +720,7 @@ const struct file_operations gfs2_file_fops = {
750 .setlease = gfs2_setlease, 720 .setlease = gfs2_setlease,
751}; 721};
752 722
753const struct file_operations gfs2_dir_fops = { 723const struct file_operations *gfs2_dir_fops = &(const struct file_operations){
754 .readdir = gfs2_readdir, 724 .readdir = gfs2_readdir,
755 .unlocked_ioctl = gfs2_ioctl, 725 .unlocked_ioctl = gfs2_ioctl,
756 .open = gfs2_open, 726 .open = gfs2_open,
@@ -760,7 +730,9 @@ const struct file_operations gfs2_dir_fops = {
760 .flock = gfs2_flock, 730 .flock = gfs2_flock,
761}; 731};
762 732
763const struct file_operations gfs2_file_fops_nolock = { 733#endif /* CONFIG_GFS2_FS_LOCKING_DLM */
734
735const struct file_operations *gfs2_file_fops_nolock = &(const struct file_operations){
764 .llseek = gfs2_llseek, 736 .llseek = gfs2_llseek,
765 .read = do_sync_read, 737 .read = do_sync_read,
766 .aio_read = generic_file_aio_read, 738 .aio_read = generic_file_aio_read,
@@ -773,10 +745,10 @@ const struct file_operations gfs2_file_fops_nolock = {
773 .fsync = gfs2_fsync, 745 .fsync = gfs2_fsync,
774 .splice_read = generic_file_splice_read, 746 .splice_read = generic_file_splice_read,
775 .splice_write = generic_file_splice_write, 747 .splice_write = generic_file_splice_write,
776 .setlease = gfs2_setlease, 748 .setlease = generic_setlease,
777}; 749};
778 750
779const struct file_operations gfs2_dir_fops_nolock = { 751const struct file_operations *gfs2_dir_fops_nolock = &(const struct file_operations){
780 .readdir = gfs2_readdir, 752 .readdir = gfs2_readdir,
781 .unlocked_ioctl = gfs2_ioctl, 753 .unlocked_ioctl = gfs2_ioctl,
782 .open = gfs2_open, 754 .open = gfs2_open,