Ejemplo n.º 1
0
static void irix_release_kernel_oplock(files_struct *fsp)
{
	if (DEBUGLVL(10)) {
		/*
		 * Check and print out the current kernel
		 * oplock state of this file.
		 */
		int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1);
		dbgtext("irix_release_kernel_oplock: file %s, dev = %x, "
			"inode = %.0f file_id = %ul, has kernel oplock state "
			"of %x.\n", fsp->fsp_name, (unsigned int)fsp->dev,
                        (double)fsp->inode, fsp->fh->file_id, state );
	}

	/*
	 * Remove the kernel oplock on this file.
	 */
	if(sys_fcntl_long(fsp->fh->fd, F_OPLKACK, OP_REVOKE) < 0) {
		if( DEBUGLVL( 0 )) {
			dbgtext("irix_release_kernel_oplock: Error when "
				"removing kernel oplock on file " );
			dbgtext("%s, dev = %x, inode = %.0f, file_id = %ul. "
				"Error was %s\n",
				fsp->fsp_name, (unsigned int)fsp->dev, 
				(double)fsp->inode, fsp->fh->file_id,
				strerror(errno) );
		}
	}
}
Ejemplo n.º 2
0
static void irix_release_kernel_oplock(struct kernel_oplocks *_ctx,
				       files_struct *fsp, int oplock_type)
{
	if (DEBUGLVL(10)) {
		/*
		 * Check and print out the current kernel
		 * oplock state of this file.
		 */
		int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1);
		dbgtext("irix_release_kernel_oplock: file %s, file_id = %s"
			"gen_id = %ul, has kernel oplock state "
			"of %x.\n", fsp_str_dbg(fsp),
		        file_id_string_tos(&fsp->file_id),
                        fsp->fh->gen_id, state );
	}

	/*
	 * Remove the kernel oplock on this file.
	 */
	if(sys_fcntl_long(fsp->fh->fd, F_OPLKACK, OP_REVOKE) < 0) {
		if( DEBUGLVL( 0 )) {
			dbgtext("irix_release_kernel_oplock: Error when "
				"removing kernel oplock on file " );
			dbgtext("%s, file_id = %s gen_id = %ul. "
				"Error was %s\n",
				fsp_str_dbg(fsp),
			        file_id_string_tos(&fsp->file_id),
				fsp->fh->gen_id,
				strerror(errno) );
		}
	}
}
Ejemplo n.º 3
0
static BOOL irix_oplocks_available(void)
{
	int fd;
	int pfd[2];
	pstring tmpname;

	set_effective_capability(KERNEL_OPLOCK_CAPABILITY);

	slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(),
		 (int)sys_getpid());

	if(pipe(pfd) != 0) {
		DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error "
			 "was %s\n",
			 strerror(errno) ));
		return False;
	}

	if((fd = sys_open(tmpname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600)) < 0) {
		DEBUG(0,("check_kernel_oplocks: Unable to open temp test file "
			 "%s. Error was %s\n",
			 tmpname, strerror(errno) ));
		unlink( tmpname );
		close(pfd[0]);
		close(pfd[1]);
		return False;
	}

	unlink(tmpname);

	if(sys_fcntl_long(fd, F_OPLKREG, pfd[1]) == -1) {
		DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not "
			 "available on this machine. Disabling kernel oplock "
			 "support.\n" ));
		close(pfd[0]);
		close(pfd[1]);
		close(fd);
		return False;
	}

	if(sys_fcntl_long(fd, F_OPLKACK, OP_REVOKE) < 0 ) {
		DEBUG(0,("check_kernel_oplocks: Error when removing kernel "
			 "oplock. Error was %s. Disabling kernel oplock "
			 "support.\n", strerror(errno) ));
		close(pfd[0]);
		close(pfd[1]);
		close(fd);
		return False;
	}

	close(pfd[0]);
	close(pfd[1]);
	close(fd);

	return True;
}
Ejemplo n.º 4
0
static bool irix_set_kernel_oplock(struct kernel_oplocks *_ctx,
				   files_struct *fsp, int oplock_type)
{
	struct irix_oplocks_context *ctx = talloc_get_type(_ctx->private_data,
					   struct irix_oplocks_context);

	if (sys_fcntl_long(fsp->fh->fd, F_OPLKREG, ctx->write_fd) == -1) {
		if(errno != EAGAIN) {
			DEBUG(0,("irix_set_kernel_oplock: Unable to get "
				 "kernel oplock on file %s, file_id %s "
				 "gen_id = %ul. Error was %s\n", 
				 fsp_str_dbg(fsp),
				 file_id_string_tos(&fsp->file_id),
				 fsp->fh->gen_id,
				 strerror(errno) ));
		} else {
			DEBUG(5,("irix_set_kernel_oplock: Refused oplock on "
				 "file %s, fd = %d, file_id = %s, "
				 "gen_id = %ul. Another process had the file "
				 "open.\n",
				 fsp_str_dbg(fsp), fsp->fh->fd,
				 file_id_string_tos(&fsp->file_id),
				 fsp->fh->gen_id ));
		}
		return False;
	}
	
	DEBUG(10,("irix_set_kernel_oplock: got kernel oplock on file %s, file_id = %s "
		  "gen_id = %ul\n",
		  fsp_str_dbg(fsp), file_id_string_tos(&fsp->file_id),
		  fsp->fh->gen_id));

	return True;
}
Ejemplo n.º 5
0
static BOOL irix_oplocks_available(void)
{
	int fd;
	int pfd[2];
	pstring tmpname;

	oplock_set_capability(True, False);

	slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)sys_getpid());

	if(pipe(pfd) != 0) {
		DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
			 strerror(errno) ));
		return False;
	}

	if((fd = sys_open(tmpname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600)) < 0) {
		DEBUG(0,("check_kernel_oplocks: Unable to open temp test file %s. Error was %s\n",
			 tmpname, strerror(errno) ));
		unlink( tmpname );
		close(pfd[0]);
		close(pfd[1]);
		return False;
	}

	unlink(tmpname);

	if(sys_fcntl_long(fd, F_OPLKREG, pfd[1]) == -1) {
		DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not available on this machine. \
Disabling kernel oplock support.\n" ));
		close(pfd[0]);
		close(pfd[1]);
		close(fd);
		return False;
	}
Ejemplo n.º 6
0
static BOOL irix_set_kernel_oplock(files_struct *fsp, int oplock_type)
{
	if (sys_fcntl_long(fsp->fh->fd, F_OPLKREG, oplock_pipe_write) == -1) {
		if(errno != EAGAIN) {
			DEBUG(0,("irix_set_kernel_oplock: Unable to get "
				 "kernel oplock on file %s, dev = %x, inode "
				 "= %.0f, file_id = %ul. Error was %s\n", 
				 fsp->fsp_name, (unsigned int)fsp->dev,
				 (double)fsp->inode, fsp->fh->file_id,
				 strerror(errno) ));
		} else {
			DEBUG(5,("irix_set_kernel_oplock: Refused oplock on "
				 "file %s, fd = %d, dev = %x, inode = %.0f, "
				 "file_id = %ul. Another process had the file "
				 "open.\n",
				 fsp->fsp_name, fsp->fh->fd,
				 (unsigned int)fsp->dev, (double)fsp->inode,
				 fsp->fh->file_id ));
		}
		return False;
	}
	
	DEBUG(10,("irix_set_kernel_oplock: got kernel oplock on file %s, dev "
		  "= %x, inode = %.0f, file_id = %ul\n",
		  fsp->fsp_name, (unsigned int)fsp->dev, (double)fsp->inode,
		  fsp->fh->file_id));

	return True;
}
Ejemplo n.º 7
0
static bool irix_oplocks_available(void)
{
    int fd;
    int pfd[2];
    TALLOC_CTX *ctx = talloc_stackframe();
    char *tmpname = NULL;

    set_effective_capability(KERNEL_OPLOCK_CAPABILITY);

    tmpname = talloc_asprintf(ctx,
                              "%s/koplock.%d",
                              lp_lockdir(),
                              (int)getpid());
    if (!tmpname) {
        TALLOC_FREE(ctx);
        return False;
    }

    if(pipe(pfd) != 0) {
        DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error "
                 "was %s\n",
                 strerror(errno) ));
        TALLOC_FREE(ctx);
        return False;
    }

    if((fd = open(tmpname, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600)) < 0) {
        DEBUG(0,("check_kernel_oplocks: Unable to open temp test file "
                 "%s. Error was %s\n",
                 tmpname, strerror(errno) ));
        unlink( tmpname );
        close(pfd[0]);
        close(pfd[1]);
        TALLOC_FREE(ctx);
        return False;
    }

    unlink(tmpname);

    TALLOC_FREE(ctx);

    if(sys_fcntl_long(fd, F_OPLKREG, pfd[1]) == -1) {
        DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not "
                 "available on this machine. Disabling kernel oplock "
                 "support.\n" ));
        close(pfd[0]);
        close(pfd[1]);
        close(fd);
        return False;
    }

    if(sys_fcntl_long(fd, F_OPLKACK, OP_REVOKE) < 0 ) {
        DEBUG(0,("check_kernel_oplocks: Error when removing kernel "
                 "oplock. Error was %s. Disabling kernel oplock "
                 "support.\n", strerror(errno) ));
        close(pfd[0]);
        close(pfd[1]);
        close(fd);
        return False;
    }

    close(pfd[0]);
    close(pfd[1]);
    close(fd);

    return True;
}