~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ocfs2/locks.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/ocfs2/locks.c (Version linux-6.11.5) and /fs/ocfs2/locks.c (Version policy-sample)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * locks.c                                        
  4  *                                                
  5  * Userspace file locking support                 
  6  *                                                
  7  * Copyright (C) 2007 Oracle.  All rights rese    
  8  */                                               
  9                                                   
 10 #include <linux/fs.h>                             
 11 #include <linux/filelock.h>                       
 12 #include <linux/fcntl.h>                          
 13                                                   
 14 #include <cluster/masklog.h>                      
 15                                                   
 16 #include "ocfs2.h"                                
 17                                                   
 18 #include "dlmglue.h"                              
 19 #include "file.h"                                 
 20 #include "inode.h"                                
 21 #include "locks.h"                                
 22                                                   
 23 static int ocfs2_do_flock(struct file *file, s    
 24                           int cmd, struct file    
 25 {                                                 
 26         int ret = 0, level = 0, trylock = 0;      
 27         struct ocfs2_file_private *fp = file->    
 28         struct ocfs2_lock_res *lockres = &fp->    
 29                                                   
 30         if (lock_is_write(fl))                    
 31                 level = 1;                        
 32         if (!IS_SETLKW(cmd))                      
 33                 trylock = 1;                      
 34                                                   
 35         mutex_lock(&fp->fp_mutex);                
 36                                                   
 37         if (lockres->l_flags & OCFS2_LOCK_ATTA    
 38             lockres->l_level > LKM_NLMODE) {      
 39                 int old_level = 0;                
 40                 struct file_lock request;         
 41                                                   
 42                 if (lockres->l_level == LKM_EX    
 43                         old_level = 1;            
 44                                                   
 45                 if (level == old_level)           
 46                         goto out;                 
 47                                                   
 48                 /*                                
 49                  * Converting an existing lock    
 50                  * atomic, so we can get away     
 51                  * here and allowing the lock     
 52                  * level.                         
 53                  */                               
 54                                                   
 55                 locks_init_lock(&request);        
 56                 request.c.flc_type = F_UNLCK;     
 57                 request.c.flc_flags = FL_FLOCK    
 58                 locks_lock_file_wait(file, &re    
 59                                                   
 60                 ocfs2_file_unlock(file);          
 61         }                                         
 62                                                   
 63         ret = ocfs2_file_lock(file, level, try    
 64         if (ret) {                                
 65                 if (ret == -EAGAIN && trylock)    
 66                         ret = -EWOULDBLOCK;       
 67                 else                              
 68                         mlog_errno(ret);          
 69                 goto out;                         
 70         }                                         
 71                                                   
 72         ret = locks_lock_file_wait(file, fl);     
 73         if (ret)                                  
 74                 ocfs2_file_unlock(file);          
 75                                                   
 76 out:                                              
 77         mutex_unlock(&fp->fp_mutex);              
 78                                                   
 79         return ret;                               
 80 }                                                 
 81                                                   
 82 static int ocfs2_do_funlock(struct file *file,    
 83 {                                                 
 84         int ret;                                  
 85         struct ocfs2_file_private *fp = file->    
 86                                                   
 87         mutex_lock(&fp->fp_mutex);                
 88         ocfs2_file_unlock(file);                  
 89         ret = locks_lock_file_wait(file, fl);     
 90         mutex_unlock(&fp->fp_mutex);              
 91                                                   
 92         return ret;                               
 93 }                                                 
 94                                                   
 95 /*                                                
 96  * Overall flow of ocfs2_flock() was influence    
 97  */                                               
 98 int ocfs2_flock(struct file *file, int cmd, st    
 99 {                                                 
100         struct inode *inode = file->f_mapping-    
101         struct ocfs2_super *osb = OCFS2_SB(ino    
102                                                   
103         if (!(fl->c.flc_flags & FL_FLOCK))        
104                 return -ENOLCK;                   
105                                                   
106         if ((osb->s_mount_opt & OCFS2_MOUNT_LO    
107             ocfs2_mount_local(osb))               
108                 return locks_lock_file_wait(fi    
109                                                   
110         if (lock_is_unlock(fl))                   
111                 return ocfs2_do_funlock(file,     
112         else                                      
113                 return ocfs2_do_flock(file, in    
114 }                                                 
115                                                   
116 int ocfs2_lock(struct file *file, int cmd, str    
117 {                                                 
118         struct inode *inode = file->f_mapping-    
119         struct ocfs2_super *osb = OCFS2_SB(ino    
120                                                   
121         if (!(fl->c.flc_flags & FL_POSIX))        
122                 return -ENOLCK;                   
123                                                   
124         return ocfs2_plock(osb->cconn, OCFS2_I    
125 }                                                 
126                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php