9
9
*
10
10
*/
11
11
#include <linux/fs.h>
12
- #define _NEED_FILE_LOCK_FIELD_MACROS
13
12
#include <linux/filelock.h>
14
13
#include <linux/backing-dev.h>
15
14
#include <linux/stat.h>
@@ -1313,20 +1312,20 @@ cifs_lock_test(struct cifsFileInfo *cfile, __u64 offset, __u64 length,
1313
1312
down_read (& cinode -> lock_sem );
1314
1313
1315
1314
exist = cifs_find_lock_conflict (cfile , offset , length , type ,
1316
- flock -> fl_flags , & conf_lock ,
1315
+ flock -> c . flc_flags , & conf_lock ,
1317
1316
CIFS_LOCK_OP );
1318
1317
if (exist ) {
1319
1318
flock -> fl_start = conf_lock -> offset ;
1320
1319
flock -> fl_end = conf_lock -> offset + conf_lock -> length - 1 ;
1321
- flock -> fl_pid = conf_lock -> pid ;
1320
+ flock -> c . flc_pid = conf_lock -> pid ;
1322
1321
if (conf_lock -> type & server -> vals -> shared_lock_type )
1323
- flock -> fl_type = F_RDLCK ;
1322
+ flock -> c . flc_type = F_RDLCK ;
1324
1323
else
1325
- flock -> fl_type = F_WRLCK ;
1324
+ flock -> c . flc_type = F_WRLCK ;
1326
1325
} else if (!cinode -> can_cache_brlcks )
1327
1326
rc = 1 ;
1328
1327
else
1329
- flock -> fl_type = F_UNLCK ;
1328
+ flock -> c . flc_type = F_UNLCK ;
1330
1329
1331
1330
up_read (& cinode -> lock_sem );
1332
1331
return rc ;
@@ -1402,16 +1401,16 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
1402
1401
{
1403
1402
int rc = 0 ;
1404
1403
struct cifsInodeInfo * cinode = CIFS_I (file_inode (file ));
1405
- unsigned char saved_type = flock -> fl_type ;
1404
+ unsigned char saved_type = flock -> c . flc_type ;
1406
1405
1407
- if ((flock -> fl_flags & FL_POSIX ) == 0 )
1406
+ if ((flock -> c . flc_flags & FL_POSIX ) == 0 )
1408
1407
return 1 ;
1409
1408
1410
1409
down_read (& cinode -> lock_sem );
1411
1410
posix_test_lock (file , flock );
1412
1411
1413
1412
if (lock_is_unlock (flock ) && !cinode -> can_cache_brlcks ) {
1414
- flock -> fl_type = saved_type ;
1413
+ flock -> c . flc_type = saved_type ;
1415
1414
rc = 1 ;
1416
1415
}
1417
1416
@@ -1432,7 +1431,7 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
1432
1431
struct cifsInodeInfo * cinode = CIFS_I (file_inode (file ));
1433
1432
int rc = FILE_LOCK_DEFERRED + 1 ;
1434
1433
1435
- if ((flock -> fl_flags & FL_POSIX ) == 0 )
1434
+ if ((flock -> c . flc_flags & FL_POSIX ) == 0 )
1436
1435
return rc ;
1437
1436
1438
1437
cifs_down_write (& cinode -> lock_sem );
@@ -1583,6 +1582,8 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
1583
1582
el = locks_to_send .next ;
1584
1583
spin_lock (& flctx -> flc_lock );
1585
1584
for_each_file_lock (flock , & flctx -> flc_posix ) {
1585
+ unsigned char ftype = flock -> c .flc_type ;
1586
+
1586
1587
if (el == & locks_to_send ) {
1587
1588
/*
1588
1589
* The list ended. We don't have enough allocated
@@ -1592,12 +1593,12 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
1592
1593
break ;
1593
1594
}
1594
1595
length = cifs_flock_len (flock );
1595
- if (lock_is_read ( flock ) || flock -> fl_type == F_SHLCK )
1596
+ if (ftype == F_RDLCK || ftype == F_SHLCK )
1596
1597
type = CIFS_RDLCK ;
1597
1598
else
1598
1599
type = CIFS_WRLCK ;
1599
1600
lck = list_entry (el , struct lock_to_push , llist );
1600
- lck -> pid = hash_lockowner (flock -> fl_owner );
1601
+ lck -> pid = hash_lockowner (flock -> c . flc_owner );
1601
1602
lck -> netfid = cfile -> fid .netfid ;
1602
1603
lck -> length = length ;
1603
1604
lck -> type = type ;
@@ -1664,22 +1665,23 @@ static void
1664
1665
cifs_read_flock (struct file_lock * flock , __u32 * type , int * lock , int * unlock ,
1665
1666
bool * wait_flag , struct TCP_Server_Info * server )
1666
1667
{
1667
- if (flock -> fl_flags & FL_POSIX )
1668
+ if (flock -> c . flc_flags & FL_POSIX )
1668
1669
cifs_dbg (FYI , "Posix\n" );
1669
- if (flock -> fl_flags & FL_FLOCK )
1670
+ if (flock -> c . flc_flags & FL_FLOCK )
1670
1671
cifs_dbg (FYI , "Flock\n" );
1671
- if (flock -> fl_flags & FL_SLEEP ) {
1672
+ if (flock -> c . flc_flags & FL_SLEEP ) {
1672
1673
cifs_dbg (FYI , "Blocking lock\n" );
1673
1674
* wait_flag = true;
1674
1675
}
1675
- if (flock -> fl_flags & FL_ACCESS )
1676
+ if (flock -> c . flc_flags & FL_ACCESS )
1676
1677
cifs_dbg (FYI , "Process suspended by mandatory locking - not implemented yet\n" );
1677
- if (flock -> fl_flags & FL_LEASE )
1678
+ if (flock -> c . flc_flags & FL_LEASE )
1678
1679
cifs_dbg (FYI , "Lease on file - not implemented yet\n" );
1679
- if (flock -> fl_flags &
1680
+ if (flock -> c . flc_flags &
1680
1681
(~(FL_POSIX | FL_FLOCK | FL_SLEEP |
1681
1682
FL_ACCESS | FL_LEASE | FL_CLOSE | FL_OFDLCK )))
1682
- cifs_dbg (FYI , "Unknown lock flags 0x%x\n" , flock -> fl_flags );
1683
+ cifs_dbg (FYI , "Unknown lock flags 0x%x\n" ,
1684
+ flock -> c .flc_flags );
1683
1685
1684
1686
* type = server -> vals -> large_lock_type ;
1685
1687
if (lock_is_write (flock )) {
@@ -1695,11 +1697,11 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
1695
1697
cifs_dbg (FYI , "F_RDLCK\n" );
1696
1698
* type |= server -> vals -> shared_lock_type ;
1697
1699
* lock = 1 ;
1698
- } else if (flock -> fl_type == F_EXLCK ) {
1700
+ } else if (flock -> c . flc_type == F_EXLCK ) {
1699
1701
cifs_dbg (FYI , "F_EXLCK\n" );
1700
1702
* type |= server -> vals -> exclusive_lock_type ;
1701
1703
* lock = 1 ;
1702
- } else if (flock -> fl_type == F_SHLCK ) {
1704
+ } else if (flock -> c . flc_type == F_SHLCK ) {
1703
1705
cifs_dbg (FYI , "F_SHLCK\n" );
1704
1706
* type |= server -> vals -> shared_lock_type ;
1705
1707
* lock = 1 ;
@@ -1731,7 +1733,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1731
1733
else
1732
1734
posix_lock_type = CIFS_WRLCK ;
1733
1735
rc = CIFSSMBPosixLock (xid , tcon , netfid ,
1734
- hash_lockowner (flock -> fl_owner ),
1736
+ hash_lockowner (flock -> c . flc_owner ),
1735
1737
flock -> fl_start , length , flock ,
1736
1738
posix_lock_type , wait_flag );
1737
1739
return rc ;
@@ -1748,15 +1750,15 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1748
1750
if (rc == 0 ) {
1749
1751
rc = server -> ops -> mand_lock (xid , cfile , flock -> fl_start , length ,
1750
1752
type , 0 , 1 , false);
1751
- flock -> fl_type = F_UNLCK ;
1753
+ flock -> c . flc_type = F_UNLCK ;
1752
1754
if (rc != 0 )
1753
1755
cifs_dbg (VFS , "Error unlocking previously locked range %d during test of lock\n" ,
1754
1756
rc );
1755
1757
return 0 ;
1756
1758
}
1757
1759
1758
1760
if (type & server -> vals -> shared_lock_type ) {
1759
- flock -> fl_type = F_WRLCK ;
1761
+ flock -> c . flc_type = F_WRLCK ;
1760
1762
return 0 ;
1761
1763
}
1762
1764
@@ -1768,12 +1770,12 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
1768
1770
if (rc == 0 ) {
1769
1771
rc = server -> ops -> mand_lock (xid , cfile , flock -> fl_start , length ,
1770
1772
type | server -> vals -> shared_lock_type , 0 , 1 , false);
1771
- flock -> fl_type = F_RDLCK ;
1773
+ flock -> c . flc_type = F_RDLCK ;
1772
1774
if (rc != 0 )
1773
1775
cifs_dbg (VFS , "Error unlocking previously locked range %d during test of lock\n" ,
1774
1776
rc );
1775
1777
} else
1776
- flock -> fl_type = F_WRLCK ;
1778
+ flock -> c . flc_type = F_WRLCK ;
1777
1779
1778
1780
return 0 ;
1779
1781
}
@@ -1941,7 +1943,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1941
1943
posix_lock_type = CIFS_UNLCK ;
1942
1944
1943
1945
rc = CIFSSMBPosixLock (xid , tcon , cfile -> fid .netfid ,
1944
- hash_lockowner (flock -> fl_owner ),
1946
+ hash_lockowner (flock -> c . flc_owner ),
1945
1947
flock -> fl_start , length ,
1946
1948
NULL , posix_lock_type , wait_flag );
1947
1949
goto out ;
@@ -1951,7 +1953,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1951
1953
struct cifsLockInfo * lock ;
1952
1954
1953
1955
lock = cifs_lock_init (flock -> fl_start , length , type ,
1954
- flock -> fl_flags );
1956
+ flock -> c . flc_flags );
1955
1957
if (!lock )
1956
1958
return - ENOMEM ;
1957
1959
@@ -1990,7 +1992,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1990
1992
rc = server -> ops -> mand_unlock_range (cfile , flock , xid );
1991
1993
1992
1994
out :
1993
- if ((flock -> fl_flags & FL_POSIX ) || (flock -> fl_flags & FL_FLOCK )) {
1995
+ if ((flock -> c . flc_flags & FL_POSIX ) || (flock -> c . flc_flags & FL_FLOCK )) {
1994
1996
/*
1995
1997
* If this is a request to remove all locks because we
1996
1998
* are closing the file, it doesn't matter if the
@@ -1999,7 +2001,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
1999
2001
*/
2000
2002
if (rc ) {
2001
2003
cifs_dbg (VFS , "%s failed rc=%d\n" , __func__ , rc );
2002
- if (!(flock -> fl_flags & FL_CLOSE ))
2004
+ if (!(flock -> c . flc_flags & FL_CLOSE ))
2003
2005
return rc ;
2004
2006
}
2005
2007
rc = locks_lock_file_wait (file , flock );
@@ -2020,7 +2022,7 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
2020
2022
2021
2023
xid = get_xid ();
2022
2024
2023
- if (!(fl -> fl_flags & FL_FLOCK )) {
2025
+ if (!(fl -> c . flc_flags & FL_FLOCK )) {
2024
2026
rc = - ENOLCK ;
2025
2027
free_xid (xid );
2026
2028
return rc ;
@@ -2071,7 +2073,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
2071
2073
xid = get_xid ();
2072
2074
2073
2075
cifs_dbg (FYI , "%s: %pD2 cmd=0x%x type=0x%x flags=0x%x r=%lld:%lld\n" , __func__ , file , cmd ,
2074
- flock -> fl_flags , flock -> fl_type , (long long )flock -> fl_start ,
2076
+ flock -> c .flc_flags , flock -> c .flc_type ,
2077
+ (long long )flock -> fl_start ,
2075
2078
(long long )flock -> fl_end );
2076
2079
2077
2080
cfile = (struct cifsFileInfo * )file -> private_data ;
0 commit comments