Skip to content

Commit

Permalink
OS-5873 Need NFS client lockd support: fcntl F_SETLK returns ENOLCK i…
Browse files Browse the repository at this point in the history
…n LX zone

Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Ryan Zezeski <ryan.zeseski@joyent.com>
Approved by: Patrick Mooney <patrick.mooney@joyent.com>
  • Loading branch information
jjelinek committed Mar 24, 2017
1 parent 751479c commit 6e02122
Show file tree
Hide file tree
Showing 11 changed files with 2,711 additions and 6 deletions.
1 change: 1 addition & 0 deletions manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5087,6 +5087,7 @@ f usr/lib/brand/lx/lx_boot_zone_busybox 0755 root root
f usr/lib/brand/lx/lx_boot_zone_ubuntu 0755 root root
f usr/lib/brand/lx/lxinit 0755 root root
f usr/lib/brand/lx/lx_librtld_db.so.1 0755 root root
f usr/lib/brand/lx/lx_lockd 0755 root root
f usr/lib/brand/lx/lx_support 0755 root root
f usr/lib/brand/lx/lx_vdso.so.1 0755 root root
f usr/lib/brand/lx/platform.xml 0444 root root
Expand Down
4 changes: 2 additions & 2 deletions usr/src/lib/brand/lx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# Copyright 2016 Joyent, Inc.
# Copyright 2017 Joyent, Inc.
#

default: all
Expand All @@ -32,7 +32,7 @@ include Makefile.lx
# Build everything in parallel; use .WAIT for dependencies
.PARALLEL:

SUBDIRS= librtld_db lx_support lx_init lx_brand netfiles \
SUBDIRS= librtld_db lx_support lx_init lx_lockd lx_brand netfiles \
zone lx_vdso testing .WAIT
MSGSUBDIRS= lx_brand lx_support zone

Expand Down
19 changes: 16 additions & 3 deletions usr/src/lib/brand/lx/lx_brand/common/mount_nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
#include <assert.h>
#include <sys/lx_mount.h>
#include <sys/lx_misc.h>
#include <sys/syscall.h>

#ifndef NFS_VERSMAX
#define NFS_VERSMAX 4
Expand Down Expand Up @@ -238,6 +239,7 @@ typedef struct nfs_mnt_data {
char *nmd_fstype;
seconfig_t nmd_nfs_sec;
int nmd_sec_opt; /* any security option ? */
int nmd_nolock_opt; /* 'nolock' specified */
rpcvers_t nmd_mnt_vers;
rpcvers_t nmd_nfsvers;
} nfs_mnt_data_t;
Expand Down Expand Up @@ -1233,7 +1235,7 @@ get_nfs_kv(char *vs, char **kp, char **vp)
* mountvers=3,mountproto=tcp,mountport=63484
*/
static int
convert_nfs_arg_str(char *srcp, char *mntopts)
convert_nfs_arg_str(char *srcp, char *mntopts, nfs_mnt_data_t *nmdp)
{
char *key, *val, *p;
char tmpbuf[MAX_MNTOPT_STR];
Expand Down Expand Up @@ -1310,6 +1312,13 @@ convert_nfs_arg_str(char *srcp, char *mntopts)
if (r != 0)
return (r);
no_sec = B_FALSE;
} else if (strcmp(key, "nolock") == 0) {
int r;
nmdp->nmd_nolock_opt = 1;
r = append_opt(mntopts, MAX_MNTOPT_STR, key,
val);
if (r != 0)
return (r);
} else {
int r;

Expand Down Expand Up @@ -1378,7 +1387,7 @@ lx_nfs_mount(char *srcp, char *mntp, char *fst, int lx_flags, char *opts)
* looked up. This also converts the opts string so that we'll be
* dealing with illumos options after this.
*/
if ((r = convert_nfs_arg_str(srcp, opts)) < 0) {
if ((r = convert_nfs_arg_str(srcp, opts, nmdp)) < 0) {
return (r);
}

Expand Down Expand Up @@ -1460,8 +1469,12 @@ lx_nfs_mount(char *srcp, char *mntp, char *fst, int lx_flags, char *opts)

r = mount(srcp, mntp, il_flags, nmdp->nmd_fstype, argp, sizeof (*argp),
opts, MAX_MNTOPT_STR);
if (r != 0)
if (r != 0) {
r = -errno;
} else if (nmdp->nmd_nolock_opt == 0) {
(void) syscall(SYS_brand, B_START_NFS_LOCKD);
}

out:
if (nconf != NULL)
freenetconfigent(nconf);
Expand Down
61 changes: 61 additions & 0 deletions usr/src/lib/brand/lx/lx_lockd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.

#
# Copyright 2017 Joyent, Inc.
#

PROG = lx_lockd

PROG_OBJS = lockd.o nfs_tbind.o
UTIL_OBJS = thrpool.o

OBJS = $(PROG_OBJS) $(UTIL_OBJS)
SRCS = $(PROG_OBJS:%.o=%.c)

all: $(PROG)

include ../Makefile.lx
include $(SRC)/cmd/Makefile.cmd

# override the install directory
ROOTBIN = $(ROOTBRANDDIR)
CLOBBERFILES = $(OBJS) $(ROOTPROG)

CPPFLAGS += -I$(SRC)/cmd/fs.d/nfs/lib
C99MODE = $(C99_ENABLE)
LDLIBS += -lnsl -lsocket

CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-uninitialized

.KEEP_STATE:

install: all $(ROOTPROG)

clean:
$(RM) $(PROG) $(OBJS)

lint:
$(LINT.c) -erroff=E_SEC_PRINTF_VAR_FMT lockd.c $(LDLIBS)

$(PROG): $(OBJS)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)

%.o: %.c
$(COMPILE.c) $<
$(POST_PROCESS_O)

%.o: $(SRC)/cmd/fs.d/nfs/lib/%.c
$(COMPILE.c) $<
$(POST_PROCESS_O)

include $(SRC)/cmd/Makefile.targ

0 comments on commit 6e02122

Please sign in to comment.