Skip to content

Commit 84e286c

Browse files
jtlaytonbrauner
authored andcommitted
smb/client: adapt to breakup of struct file_lock
Most of the existing APIs have remained the same, but subsystems that access file_lock fields directly need to reach into struct file_lock_core now. Signed-off-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent c8df2cc commit 84e286c

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

fs/smb/client/cifsglob.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <uapi/linux/cifs/cifs_mount.h>
2727
#include "../common/smb2pdu.h"
2828
#include "smb2pdu.h"
29-
#define _NEED_FILE_LOCK_FIELD_MACROS
3029
#include <linux/filelock.h>
3130

3231
#define SMB_PATH_MAX 260

fs/smb/client/cifssmb.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
/* want to reuse a stale file handle and only the caller knows the file info */
1616

1717
#include <linux/fs.h>
18-
#define _NEED_FILE_LOCK_FIELD_MACROS
1918
#include <linux/filelock.h>
2019
#include <linux/kernel.h>
2120
#include <linux/vfs.h>
@@ -2067,20 +2066,20 @@ CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
20672066
parm_data = (struct cifs_posix_lock *)
20682067
((char *)&pSMBr->hdr.Protocol + data_offset);
20692068
if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
2070-
pLockData->fl_type = F_UNLCK;
2069+
pLockData->c.flc_type = F_UNLCK;
20712070
else {
20722071
if (parm_data->lock_type ==
20732072
cpu_to_le16(CIFS_RDLCK))
2074-
pLockData->fl_type = F_RDLCK;
2073+
pLockData->c.flc_type = F_RDLCK;
20752074
else if (parm_data->lock_type ==
20762075
cpu_to_le16(CIFS_WRLCK))
2077-
pLockData->fl_type = F_WRLCK;
2076+
pLockData->c.flc_type = F_WRLCK;
20782077

20792078
pLockData->fl_start = le64_to_cpu(parm_data->start);
20802079
pLockData->fl_end = pLockData->fl_start +
20812080
(le64_to_cpu(parm_data->length) ?
20822081
le64_to_cpu(parm_data->length) - 1 : 0);
2083-
pLockData->fl_pid = -le32_to_cpu(parm_data->pid);
2082+
pLockData->c.flc_pid = -le32_to_cpu(parm_data->pid);
20842083
}
20852084
}
20862085

fs/smb/client/file.c

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*
1010
*/
1111
#include <linux/fs.h>
12-
#define _NEED_FILE_LOCK_FIELD_MACROS
1312
#include <linux/filelock.h>
1413
#include <linux/backing-dev.h>
1514
#include <linux/stat.h>
@@ -1313,20 +1312,20 @@ cifs_lock_test(struct cifsFileInfo *cfile, __u64 offset, __u64 length,
13131312
down_read(&cinode->lock_sem);
13141313

13151314
exist = cifs_find_lock_conflict(cfile, offset, length, type,
1316-
flock->fl_flags, &conf_lock,
1315+
flock->c.flc_flags, &conf_lock,
13171316
CIFS_LOCK_OP);
13181317
if (exist) {
13191318
flock->fl_start = conf_lock->offset;
13201319
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;
13221321
if (conf_lock->type & server->vals->shared_lock_type)
1323-
flock->fl_type = F_RDLCK;
1322+
flock->c.flc_type = F_RDLCK;
13241323
else
1325-
flock->fl_type = F_WRLCK;
1324+
flock->c.flc_type = F_WRLCK;
13261325
} else if (!cinode->can_cache_brlcks)
13271326
rc = 1;
13281327
else
1329-
flock->fl_type = F_UNLCK;
1328+
flock->c.flc_type = F_UNLCK;
13301329

13311330
up_read(&cinode->lock_sem);
13321331
return rc;
@@ -1402,16 +1401,16 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
14021401
{
14031402
int rc = 0;
14041403
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;
14061405

1407-
if ((flock->fl_flags & FL_POSIX) == 0)
1406+
if ((flock->c.flc_flags & FL_POSIX) == 0)
14081407
return 1;
14091408

14101409
down_read(&cinode->lock_sem);
14111410
posix_test_lock(file, flock);
14121411

14131412
if (lock_is_unlock(flock) && !cinode->can_cache_brlcks) {
1414-
flock->fl_type = saved_type;
1413+
flock->c.flc_type = saved_type;
14151414
rc = 1;
14161415
}
14171416

@@ -1432,7 +1431,7 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
14321431
struct cifsInodeInfo *cinode = CIFS_I(file_inode(file));
14331432
int rc = FILE_LOCK_DEFERRED + 1;
14341433

1435-
if ((flock->fl_flags & FL_POSIX) == 0)
1434+
if ((flock->c.flc_flags & FL_POSIX) == 0)
14361435
return rc;
14371436

14381437
cifs_down_write(&cinode->lock_sem);
@@ -1583,6 +1582,8 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
15831582
el = locks_to_send.next;
15841583
spin_lock(&flctx->flc_lock);
15851584
for_each_file_lock(flock, &flctx->flc_posix) {
1585+
unsigned char ftype = flock->c.flc_type;
1586+
15861587
if (el == &locks_to_send) {
15871588
/*
15881589
* The list ended. We don't have enough allocated
@@ -1592,12 +1593,12 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
15921593
break;
15931594
}
15941595
length = cifs_flock_len(flock);
1595-
if (lock_is_read(flock) || flock->fl_type == F_SHLCK)
1596+
if (ftype == F_RDLCK || ftype == F_SHLCK)
15961597
type = CIFS_RDLCK;
15971598
else
15981599
type = CIFS_WRLCK;
15991600
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);
16011602
lck->netfid = cfile->fid.netfid;
16021603
lck->length = length;
16031604
lck->type = type;
@@ -1664,22 +1665,23 @@ static void
16641665
cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
16651666
bool *wait_flag, struct TCP_Server_Info *server)
16661667
{
1667-
if (flock->fl_flags & FL_POSIX)
1668+
if (flock->c.flc_flags & FL_POSIX)
16681669
cifs_dbg(FYI, "Posix\n");
1669-
if (flock->fl_flags & FL_FLOCK)
1670+
if (flock->c.flc_flags & FL_FLOCK)
16701671
cifs_dbg(FYI, "Flock\n");
1671-
if (flock->fl_flags & FL_SLEEP) {
1672+
if (flock->c.flc_flags & FL_SLEEP) {
16721673
cifs_dbg(FYI, "Blocking lock\n");
16731674
*wait_flag = true;
16741675
}
1675-
if (flock->fl_flags & FL_ACCESS)
1676+
if (flock->c.flc_flags & FL_ACCESS)
16761677
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)
16781679
cifs_dbg(FYI, "Lease on file - not implemented yet\n");
1679-
if (flock->fl_flags &
1680+
if (flock->c.flc_flags &
16801681
(~(FL_POSIX | FL_FLOCK | FL_SLEEP |
16811682
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);
16831685

16841686
*type = server->vals->large_lock_type;
16851687
if (lock_is_write(flock)) {
@@ -1695,11 +1697,11 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock,
16951697
cifs_dbg(FYI, "F_RDLCK\n");
16961698
*type |= server->vals->shared_lock_type;
16971699
*lock = 1;
1698-
} else if (flock->fl_type == F_EXLCK) {
1700+
} else if (flock->c.flc_type == F_EXLCK) {
16991701
cifs_dbg(FYI, "F_EXLCK\n");
17001702
*type |= server->vals->exclusive_lock_type;
17011703
*lock = 1;
1702-
} else if (flock->fl_type == F_SHLCK) {
1704+
} else if (flock->c.flc_type == F_SHLCK) {
17031705
cifs_dbg(FYI, "F_SHLCK\n");
17041706
*type |= server->vals->shared_lock_type;
17051707
*lock = 1;
@@ -1731,7 +1733,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
17311733
else
17321734
posix_lock_type = CIFS_WRLCK;
17331735
rc = CIFSSMBPosixLock(xid, tcon, netfid,
1734-
hash_lockowner(flock->fl_owner),
1736+
hash_lockowner(flock->c.flc_owner),
17351737
flock->fl_start, length, flock,
17361738
posix_lock_type, wait_flag);
17371739
return rc;
@@ -1748,15 +1750,15 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
17481750
if (rc == 0) {
17491751
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
17501752
type, 0, 1, false);
1751-
flock->fl_type = F_UNLCK;
1753+
flock->c.flc_type = F_UNLCK;
17521754
if (rc != 0)
17531755
cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
17541756
rc);
17551757
return 0;
17561758
}
17571759

17581760
if (type & server->vals->shared_lock_type) {
1759-
flock->fl_type = F_WRLCK;
1761+
flock->c.flc_type = F_WRLCK;
17601762
return 0;
17611763
}
17621764

@@ -1768,12 +1770,12 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type,
17681770
if (rc == 0) {
17691771
rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
17701772
type | server->vals->shared_lock_type, 0, 1, false);
1771-
flock->fl_type = F_RDLCK;
1773+
flock->c.flc_type = F_RDLCK;
17721774
if (rc != 0)
17731775
cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n",
17741776
rc);
17751777
} else
1776-
flock->fl_type = F_WRLCK;
1778+
flock->c.flc_type = F_WRLCK;
17771779

17781780
return 0;
17791781
}
@@ -1941,7 +1943,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
19411943
posix_lock_type = CIFS_UNLCK;
19421944

19431945
rc = CIFSSMBPosixLock(xid, tcon, cfile->fid.netfid,
1944-
hash_lockowner(flock->fl_owner),
1946+
hash_lockowner(flock->c.flc_owner),
19451947
flock->fl_start, length,
19461948
NULL, posix_lock_type, wait_flag);
19471949
goto out;
@@ -1951,7 +1953,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
19511953
struct cifsLockInfo *lock;
19521954

19531955
lock = cifs_lock_init(flock->fl_start, length, type,
1954-
flock->fl_flags);
1956+
flock->c.flc_flags);
19551957
if (!lock)
19561958
return -ENOMEM;
19571959

@@ -1990,7 +1992,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
19901992
rc = server->ops->mand_unlock_range(cfile, flock, xid);
19911993

19921994
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)) {
19941996
/*
19951997
* If this is a request to remove all locks because we
19961998
* 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,
19992001
*/
20002002
if (rc) {
20012003
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))
20032005
return rc;
20042006
}
20052007
rc = locks_lock_file_wait(file, flock);
@@ -2020,7 +2022,7 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
20202022

20212023
xid = get_xid();
20222024

2023-
if (!(fl->fl_flags & FL_FLOCK)) {
2025+
if (!(fl->c.flc_flags & FL_FLOCK)) {
20242026
rc = -ENOLCK;
20252027
free_xid(xid);
20262028
return rc;
@@ -2071,7 +2073,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
20712073
xid = get_xid();
20722074

20732075
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,
20752078
(long long)flock->fl_end);
20762079

20772080
cfile = (struct cifsFileInfo *)file->private_data;

fs/smb/client/smb2file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*
88
*/
99
#include <linux/fs.h>
10-
#define _NEED_FILE_LOCK_FIELD_MACROS
1110
#include <linux/filelock.h>
1211
#include <linux/stat.h>
1312
#include <linux/slab.h>
@@ -229,7 +228,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
229228
* flock and OFD lock are associated with an open
230229
* file description, not the process.
231230
*/
232-
if (!(flock->fl_flags & (FL_FLOCK | FL_OFDLCK)))
231+
if (!(flock->c.flc_flags & (FL_FLOCK | FL_OFDLCK)))
233232
continue;
234233
if (cinode->can_cache_brlcks) {
235234
/*

0 commit comments

Comments
 (0)